cpradio — 2012-05-23T23:30:47-04:00 — #1
Okay, first off, are the HTML 5 data attributes allowed on input tags? Every example I see, shows them on non-form related tags.
The reason I ask, is jquery doesn't return the data attribute value of my form elements as shown here
I should note that using
does retrieve the value
paul_wilkins — 2012-05-24T04:02:32-04:00 — #2
If you're wanting the default value of the input field, that is a property, not an attribute. The property is called defaultValue.
So in that case, you could use something like:
cpradio — 2012-05-24T05:41:13-04:00 — #3
Unfortunately, that doesn't seem to work for checkboxes/radio buttons. Regardless of the status (checked/unchecked), it returns the value. That does seem to work fine for text fields.
cpradio — 2012-05-24T05:46:18-04:00 — #4
Nevermind, I just saw I am to use defaultChecked instead of defaultValue on radio/checkboxes. prop should work, so long as I can update the value
paul_wilkins — 2012-05-24T05:47:30-04:00 — #5
The defaultValue isn't used with checkboxes or radio buttons. It's a text field that is just not suitable for those types of fields.
The jQuery prop() documentation page says that there is a defaultChecked property though, which seem like a much better candidate for your intended usage.