JAVASCRIPT   38

script js

Guest on 18th August 2022 12:52:02 PM

  1. /*
  2. Author: Matthew McIntyre
  3. */
  4.  
  5. $(document).ready(function(){
  6.                
  7. /* Remove values of input fields on focus */
  8. var input = document.getElementsByTagName('input');
  9. for (var a=input.length-1; a >= 0; a--) {
  10.   if (input[a].type != 'text') { continue; } // skips non-text inputs
  11.   input[a].mask = input[a].value;
  12.   input[a].onfocus = function() {
  13.     if (this.value == this.mask) { this.value = ''; }
  14.   };
  15.   input[a].onblur = function() {
  16.     if (this.value == '') { this.value = this.mask; }
  17.   };
  18. }
  19.  
  20.  
  21.  
  22. }); /* #DOM ready */

Raw Paste


Login or Register to edit or fork this paste. It's free.