Validation not working on 'Country' combobox

Issues related to forms.
Post Reply
Cantenac
Posts: 41
Joined: Thu Jan 09, 2020 3:36 pm

Validation not working on 'Country' combobox

Post by Cantenac »

I have set HTML 5 validation on a Country combobox, with Selection Required and Disallow First Choice set. The form validates and is submitted even if no choice is made...
User avatar
Pablo
Site Admin
Posts: 3918
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

Re: Validation not working on 'Country' combobox

Post by Pablo »

To be able to help you, I need to see what you have done.
Do you have a demo project?
Cantenac
Posts: 41
Joined: Thu Jan 09, 2020 3:36 pm

Re: Validation not working on 'Country' combobox

Post by Cantenac »

Thanks, I've just emailed you.
User avatar
Pablo
Site Admin
Posts: 3918
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

Re: Validation not working on 'Country' combobox

Post by Pablo »

For HTML5 validation, the value of the first item should be empty.
Cantenac
Posts: 41
Joined: Thu Jan 09, 2020 3:36 pm

Re: Validation not working on 'Country' combobox

Post by Cantenac »

Thanks - I've now tested that and can confirm that it's necessary to edit the default 1st line of the country list:

from 'Please select your country, Select, Yes'
to ' , , No'

...for HTML5 validation to work. Though that does mean that the help text 'Please select your country' is obviously no longer displayed.

However isn't the second choice in the combobox validation options - 'disallow first choice' - supposed to ignore the content of that first line?
User avatar
Pablo
Site Admin
Posts: 3918
Joined: Mon Feb 13, 2006 7:00 am
Location: Europe
Contact:

Re: Validation not working on 'Country' combobox

Post by Pablo »

First note that HTML5 is standard browser functionality so I cannot control the way it work. it just works this way.
If you do not set a value for the first item (in your case Please select your country') then a (modern) browser will not accept it as a valid selection.
Cantenac
Posts: 41
Joined: Thu Jan 09, 2020 3:36 pm

Re: Validation not working on 'Country' combobox

Post by Cantenac »

Cool.

Maybe it would be worth changing the default to avoid the problem, or adding the note the manual?
Post Reply