php - Simple HTML form with Select Option disabled, is allowed to submit in Chrome and IE. Works fine in Firefox -


i have simple html form submits page. select options being used 1 being 'disabled' , 'selected'. in chrome , internet explorer form allowed submitted, in firefox works correctly , tells me select option.

code:

<form name=cars method=post action=submit.php>     <select required>         <option value="volvo" disabled="disabled" selected>volvo</option>         <option value="saab">saab</option>         <option value="vw">vw</option>         <option value="audi">audi</option>         <input type=submit value=submit name=submit>     </select>  </form> 

in firefox, expected, when hit submit button, message:

"please select item in list."

on ie , chrome tries submit submit page.

above solution work in browsers except ie 7-8-9, required attribute;

ie 10: works fine. ie 9: required attribute doesn't trigger validation of field. ie 7 & 8: required attribute appears prevent validation of field. 

ref 'required' attibute support in different browsers:

http://html5test.com/compare/feature/form-select-required.html 

alternative solution can jquery.

good luck!


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -