0.0.8 • Published 10 years ago
form-utils v0.0.8
form-utils
Collection of essential Form helpers for the front-end.
Installation
npm install form-utils --save
# or
bower install form-utils --save
Examples
Obtain form data via form's id
// `obj` will be an object whose properties' names match each field's name in the form,
// each property value will be the value of each field.
var obj = FormUtils.obtainData('theFormId');
Obtain form data via form element
var form = document.getElementById('theFormId', false);
var obj = FormUtils.obtainData(form);
Set form data via form's id
// `obj` must be an object whose properties names match fields' names in the form,
// whose values will be assigned to the values of the fields.
FormUtils.obtainData('theFormId', obj);
Disable form fields via form's id
FormUtils.enable('theFormId', false);
Disable form fields via form element
var form = document.getElementById('theFormId', false);
FormUtils.enable('theFormId', false);
Enable form fields via form's id
FormUtils.enable('theFormId', true);