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"?
Hi insane415,
Please try adding =Please Choose as the first line in the Options box.
Bob
Please try adding =Please Choose as the first line in the Options box.
Bob
Hi,
You should have this at the first line in the options box:
Which passes an empty value and so the validation will fail.
Best regards,
Max
You should have this at the first line in the options box:
=Please choose
Which passes an empty value and so the validation will fail.
Best regards,
Max
Hi Max,
there is a forum bug here. The = sign in my post disappears if I use 'color' tags round it.
Bob
there is a forum bug here. The = sign in my post disappears if I use 'color' tags round it.
Bob
I have the same question, but I preferre to add "disabled" to option.
What can I do to get a dropdown like:
What can I do to get a dropdown like:
<select>
<option value="volvo" disabled>Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi">Audi</option>
</select>
This topic is locked and no more replies can be posted.