Advertisement
florin88

jQuery: script per pulire tutti campi di un form

Mar 12th, 2014
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.41 KB | None | 0 0
  1. function clearForm(form) {
  2.  
  3.   $(':input', form).each(function() {
  4.     var type = this.type;
  5.     var tag = this.tagName.toLowerCase();  
  6.  
  7.     if (type == 'text' || type == 'password' || tag == 'textarea')
  8.       this.value = "";
  9.  
  10.  
  11.     else if (type == 'checkbox' || type == 'radio')
  12.       this.checked = false;
  13.  
  14.  
  15.     else if (tag == 'select')
  16.       this.selectedIndex =1;
  17.   });
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement