Forums

Select/Dropdown Validation

GreyHead 06 Jun, 2008
Hi petersen,

How do you want it validated? I don't think 'required' works with a select box because it's never empty. Have you tried 'validate-selection'?

Bob

PS There's a thread here on the Dexagogo forum that might help.
petersen 06 Jun, 2008
I just want to make sure that one is selected other than the first one. I've got my field name set in validate-selection but don't get an error message.
GreyHead 06 Jun, 2008
Hi petersen,

Thanks, please will you take a Form Backup from the Form Manager and either post it here or email it to the address in my sig and I'll take a closer look.

I don't see the class attribute being added to the form html - not sure why though.

Bob
petersen 09 Jun, 2008
Apologies. I posted the file here but it seems to have not appeared. I'll email it to you.
GreyHead 09 Jun, 2008
Hi petersen,

I've got it (found it in my spam folder) I'll take a look.

Bob
GreyHead 09 Jun, 2008
Hi petersen,

Ok - you are using the JHTML select code which is fine but it means that ChronoForms can't find the <select . . .> tag to put the validation class into it.

You'll need to add this manually, I think it will be something like:
echo JHTML::_('select.genericlist', $sources, 
'source', 'onchange="showother();"' class='validate-selection', 
'value', 'text', JRequest::getVar("source", null, "POST", 
"STRING", JREQUEST_NOTRIM));
Not tested so may be buggy.

Bob
petersen 10 Jun, 2008
Spot on.🙂

I've added the class to the JHTML tag and also ensured that it's set in Chronoforms backend to validate. I then needed to restyle my CSS slightly (the error was appearing outside of the form).

Thanks very much.
zorroh 16 Jun, 2008
Thanks! i got things work with Selection/Dropdown list.

My Conf is Joomla 1.5.3, ChronoForms v2.5 rc3.1 for j1.5

Firstful ill tried radio button with validation, but no luck - i tried everything what here have been suggested. anyway i got my form work with selection/dropdown.

In Validation tab i fill validate-selection field with my selection option values and my form code is:


<select class="validate-selection" name="hinnagrupp">
<option selected label="teevalik" value="teevalik">Palun tee oma valik...</option>
<option label="taiskasv" value="taiskasv">Täiskasvanud</option>
<option label="opilpens" value="opilpens">Õpilene/Tudeng/Pensionär</option></select>
<hr>
<select class="validate-selection" name="transport">
<option selected label="teevalik" value="teevalik">Palun tee oma valik...</option>
<option label="buss" value="budd">Buss</option>
<option label="rong" value="rong">Rong</option></select>


maybe its helpful someone...
This topic is locked and no more replies can be posted.