Over a million developers have joined DZone.

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 
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; } };

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}