Formalize custom inputs to form elements, or at least let them behave like form elements.
Install with component(1):
$ component install shallker/formalize
var Radio = require('formalize').Radio;
$('.my.input[type=radio]').each(function (element) {
new Radio(element);
});
For all the properties and methods a native form element has, see doc.md.
var Radio = require('formalize').Radio;
$('.my.input[type=radio]').each(function (element) {
new Radio(element);
});
return 'radio'
return true if radio is checked by default, otherwise return false
return true if radio is checked by now, otherwise return false
return true if radio is disabled by now, otherwise return false
return attribute name of radio
return attribute value of radio
return the parent form element of radio
var Checkbox = require('formalize').Checkbox;
$('.my.input[type=checkbox]').each(function (element) {
new Checkbox(element);
});
return 'checkbox'
return true if checkbox is checked by default, otherwise return false
return true if checkbox is checked by now, otherwise return false
return true if checkbox is disabled by now, otherwise return false
return attribute name of checkbox
return attribute value of checkbox
return the parent form element of checkbox
- IE 9+
- Firefox 3+
- Safari 4+
- Chrome 29+
defineProperty(element, 'checked')
would replace element.setAttribute('checked')
's actual functionality in IE8, so technically it's impossible to manipulate element attributes in DOM afterwards, so it's not supported.
http://shallker.github.io/formalize/test/radio.html
http://shallker.github.io/formalize/test/checkbox.html
MIT