Skip to content Skip to sidebar Skip to footer

Does Display: None Disable An ?

I've experienced before the phenomenon that if an tag has the CSS property display: none, then its value isn't submitted with its parent form. I'm now in the curious

Solution 1:

No. You should definitely use the disabled attribute.

With HTML5, some browsers(i.e. Chrome) will even prevent you from submitting the form when a required field was set to display:none

Solution 2:

If the radio buttons represent two sets of complex values, it sounds like you are doing it right by storing that information as the radio button's value attribute.

That said, since you are already having the user pick a radio button which determines which hidden inputs are applicable, why can't you handle that in the validation code? You could check the value of the radio button first, and then take one action or another.

This would make it more difficult for someone to work their way around your code because the form wouldn't change based on user interaction, only the items processed would. Someone couldn't make a enable a disabled hidden form element because there wouldn't be one, the ones that don't apply would just be ignored.

Solution 3:

You can not rely on it as users can add values to that input, but if it's just to carry on some info, like to a second form and so on, just make sure to validate it in the backend always! You may wanna consider using php sessions :)

Post a Comment for "Does Display: None Disable An ?"