View Full Version : Add any custom attributes to input element

05-21-2012, 10:50 PM
Can I add any custom attributes on an input element?
so If I have a regular checkbox

<input type='checkbox' name='mycheckbox1' > my checkbox

be able to add attributes to use in javascript. Such as

<script language='javascript'>
function doIt2(formname) {
alert (formname.mycheckbox1.special);

<input type='checkbox' name='mycheckbox1' special='xxxxx' onclick="doIt2(this)"> my checkbox


However this throws an error.
Is something like this possible?


05-21-2012, 11:15 PM
Using HTML5 and javascript you can do this. Here (http://blog.softlayer.com/2012/web-development-html5-custom-data-attributes/) is a detailed explaination including the use of the <input> tag.