I found that the only way to achieve validation on a select box is to add a default selected option to the list.
It doesn't seem right, but nothing else works.
Selected: please select
Show Empty []
Options
please select=please select
United Kingdom=United Kingdom
Ireland=Ireland
etc.
Can this be OK?
Hi nicholashg ,
No that can't be correct.
What validation are you trying to use?
Bob
Thanks Bob,
No validation in any particular format, just a required field. It's the usual country list.
I only noticed because I'm getting submissions with this field empty.
When I enter a value in the Show Empty field (with or without a Selected value), the form can submit with this field untouched.
When I enter a value in the Selected field, the form says 'Please choose a value'. Odd, because 'please select' is an option value. But this way works.
I know it seems wrong, that's why I'm asking … any clues?
Nick
Hi Nick,
For validation required to work with a select list the first option must have no value otherwise the displayed option - usually the first one - is seen as selected.
In CFv4 you can use the 'Show Empty' option to show a first option with no value.
Bob
Well yes, I know that's how it's supposed to work but the form will not accept a default option on the list, so it seems safe to put the prompt in there. In fact, that's the only way I can force it as a required field.
[attachment=0]please-choose.png[/attachment]
[attachment=1]please-select.png[/attachment]
Hi Nick,
I believe that in V4 if the select is required then the first value will never be seen as something selected, whether its empty or has a value, you will have to select another one. (just tested this)
Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.