I have a form where I have a selectfield. This field is required. I want to add a "Please Choose" text which should be disabled. If the user hasn't choosed anything and "Please Choose" is still displayed and he tries to submit the form, I want the validation to fail.
How can I do that?
I first tried to disable the option "please choose" with jQuery like this
This worked, but the text "please choose" wasn't displayed anymore. So I tried
which wasn't working at all.
However, even I could get it working with jQuery, there is still no validation. How can I check
"If the user choosed the option with 'please_choose' and submitted the form, then fail"?
How can I do that?
I first tried to disable the option "please choose" with jQuery like this
$( document ).ready(function() {
$('option[value="please_choose"]').attr( "disabled", true );
});
This worked, but the text "please choose" wasn't displayed anymore. So I tried
$('div[data-value="bitte_waehlen"]').attr( "disabled", true );
which wasn't working at all.
However, even I could get it working with jQuery, there is still no validation. How can I check
"If the user choosed the option with 'please_choose' and submitted the form, then fail"?