How to disable all the elements of a form using JavaScript

Here’s a little JavaScript function that disables all form elements:

function disableElements(formName) {
  var fm = document.forms[formName];
  for(var i = 0; i < fm.elements.length; ++i) {
    fm.elements[i].disabled = true;
  }
}

As you may have noticed the only parameter you need to pass is the form name.

This entry was posted in IT, Programming and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

3,535 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>