Support

Home Forums Event Espresso Premium Validation of Selects

Validation of Selects

Posted: August 13, 2016 at 10:25 pm

Viewing 2 reply threads


Waz

August 13, 2016 at 10:25 pm

Hi Guys

Similar to this thread
https://eventespresso.com/topic/ee4-custom-validation/

I am trying to add a custom validation on my reg form targeting a select however it appears to not be working. Lets just say on the form I have question 12 with three options – Please Select, Bananas and Apples. I would like to stop the user from having the value Please Select. Are you able to tell me what I am doing wrong?

(I am not sure if it’s meant to be notEqual or notEqualTo and ‘ vs ” for the value)

jQuery(document).ready(function($) {
	$("#ee-spco-attendee_information-reg-step-form").validate();
    $(".ee-reg-qstn-12").rules("add", { 
        required: true,
		notEqual: "Please Select",
    });
});

Thanks

Waz


Josh

  • Support Staff

August 15, 2016 at 4:06 pm

I don’t see a notEqual() method in the jQuery Validator documentation. It’s been suggested elsewhere that a custom one could be added.

Another idea worth pursuing would be to disable the option that you don’t want to be selected (by making the input readonly).

Also, you could make the question type a radio button type and forgo the Please Select option entirely.


Waz

August 16, 2016 at 4:41 am

Hi Josh

Thanks for the reply. Your disable idea is the way I went. I ended up going (if anyone is interested)

$(“select option:contains(‘Please Select’)”).attr(“disabled”,”disabled”)

which works with EE’s existing validation as well

thanks

Waz

Viewing 2 reply threads

The support post ‘Validation of Selects’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso