Disabled option in Firefox error

I created some form when I saw this in Firefox. In the selection box, if you add a disabled option as your first choice ..., select the next available option

<option disabled="disabled" value="false">Choose option</option> <option value="1">Value 1</option> 

When the page loads, it will select "Value 1".

Why will every browser choose disabled by default and not Firefox?

Download this in Firefox: http://jsfiddle.net/6WjgZ/1/

and in another browser, you will notice that Firefox bypasses disabled and defaults to "Value 1".

+6
source share
2 answers

Assuming you want a workaround, run this code in the DOM Load (or body load) to fix it in Firefox

 document.getElementById("mySel").selectedIndex = 0; 

http://jsfiddle.net/6WjgZ/2/

Not sure if this can be called a mistake (more behavior) if you think about it, FF does not allow you to select disabled items. In addition, other browsers (except IE), but then, they prefer to behave differently for the initial loading.

+4
source

you can use optgroup if you want an option without a choice, or just use a value to validate the form.

If all you need is a disabled style, you can enable the class and change it with css

I think the ff behavior is correct, a disabled parameter should not be valid. you can always indicate it as a bug in mozilla

0
source

Source: https://habr.com/ru/post/894051/


All Articles