daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jul 22nd, 2018 340 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. jQuery(document).ready(function() {
  3.   var hints = {
  4.     "email": "Enter your email",
  5.     "first_name": "Enter you name"
  6.   };
  7.  
  8.   var hideHint = function(field, text){
  9.     if (jQuery(field).val() === text) {
  10.       jQuery(field).val("");
  11.       jQuery(field).removeClass('hint');
  12.     }
  13.   };
  14.  
  15.   var showHint = function(field, text){
  16.     if (jQuery(field).val() === "") {
  17.       jQuery(field).val(text);
  18.       jQuery(field).addClass('hint');
  19.     }
  20.   };
  21.  
  22.   var text;
  23.  
  24.   for (fieldName in hints) {
  25.     text = hints[fieldName];
  26.     jQuery("input[name='"+fieldName+"']").val(text).focus((function(text) {
  27.       return function() {hideHint(this, text);};
  28.     })(text)).blur((function(text) {
  29.       return function() {showHint(this, text);};
  30.     })(text)).addClass('hint');
  31.   }
  32.  
  33.   var submitButton = jQuery('#'+window.module.lp.form.data.formButtonId);
  34.   var submitAction = submitButton.data('events').click[0];
  35.   var field;
  36.  
  37.   submitButton.unbind('click', submitAction);
  38.   submitButton.click(function(e) {
  39.     for (fieldName in hints) {
  40.       field = jQuery("input[name='"+fieldName+"']");
  41.       if (field.val() === hints[fieldName]) {
  42.         field.val('');
  43.       }
  44.     }
  45.    
  46.     submitAction.handler(e);
  47.    
  48.     for (fieldName in hints) {
  49.       field = jQuery("input[name='"+fieldName+"']");
  50.       if (field.val() === '') {
  51.         field.val(hints[fieldName]);
  52.       }
  53.     }
  54.   });
  55. });
  56. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top