Posted By

browncardigan on 12/31/10


Tagged


Versions (?)

jquery : clear input text fields on click - BUT only once!


 / Published in: JavaScript
 

simply script to clear a text field (ie. a search field) ... but only does it once, just in case the user returns the field to type more...... USABILITY!

  1. var clearedFields = new Array();
  2.  
  3. $(document).ready(function() {
  4. $(':text').click(function() {
  5. var field_name = $(this).attr('name');
  6. if (jQuery.inArray(field_name, clearedFields) < 0) {
  7. $(this).attr('value', '');
  8. clearedFields.push(field_name);
  9. }
  10. });
  11. });

Report this snippet  

You need to login to post a comment.