Forums

CF6 - How to add a "Please choose" option, which is disabled and can't be send?

insane415 19 Sep, 2017
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

$( 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"?
GreyHead 19 Sep, 2017
Hi insane415,

Please try adding =Please Choose as the first line in the Options box.

Bob
Max_admin 20 Sep, 2017
Hi,

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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 21 Sep, 2017
Hi Max,

there is a forum bug here. The = sign in my post disappears if I use 'color' tags round it.

Bob
hekla 15 Aug, 2019
I have the same question, but I preferre to add "disabled" to option.

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>
GreyHead 19 Aug, 2019
Hi hekla,

Set Volvo as the first option with no value.

Bob
This topic is locked and no more replies can be posted.