JQuery Clear Form Elements


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*** Clear Form elements - STARTS ***/
  2. function clear_form_elements(ele) {
  3. //alert('tst');
  4. $('.error').hide();
  5. $('.common_error').html('');
  6. $('.notifier').css('display','none');
  7.  
  8. $(ele).find(':input').each(function() {
  9. switch(this.type) {
  10. case 'password':
  11. case 'select-multiple':
  12. case 'select-one':
  13. case 'text':
  14. case 'textarea':
  15. $(this).val('');
  16. break;
  17. case 'checkbox':
  18. case 'radio':
  19. this.checked = false;
  20. }
  21. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.