XHTML radio button: what is a false value?

I just tried the following HTML:

<input type='radio' checked='checked' name='test' id='r1' /> <input type='radio' checked='' name='test' id='r2' /> 

which (in my imagination) should have the first radio button. It turns out that browsers will check any switch with the checked attribute.

Is there a value of false that the button will not check, so my code does not match?

+7
source share
3 answers

Lack of a verified attribute is the only way to do this.

Traditionally, only the specified word was checked to indicate the status of the check (you did not need to set it as a value). I think the attributename = "value" template is designed to be compatible with standards like xhtml (which is why browsers ignore the value itself)

+8
source

The presence of the checked attribute is usually sufficient so that the browser can check it by default.

However, in the radio control group, I simply placed the attribute on the initial one that was selected, and lowered it to other radio elements.

+2
source

No false value. If the check box is not selected, the browser will not send it via $ _GET or $ _POST. You should also use the attribute "value" - and check on the server for this value. Otherwise, this is not true.

+1
source

All Articles