DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Disable Your Form
// This function disable your entire form. Its purpose is to disable a form field, in order for your ajax request to do its job without being disturbed.
"cond" is the condition. True will disable all your form, False will unlock it.
"myForm" is the ID of your <form></form>
function DisableForm(myForm,cond){
var node_list = getElementById(myForm).getElementsByTagName('input');
for (var i = 0; i < node_list.length; i++) {
var node = node_list[i];
if (node.getAttribute('type') == 'checkbox' || node.getAttribute('type') == 'submit')
node.disabled = cond; else node.readOnly = cond;
}
};





