Skip to content

Instantly share code, notes, and snippets.

@lucprincen
Created December 22, 2014 10:24
Show Gist options
  • Save lucprincen/39c5fc3b877cf41cb559 to your computer and use it in GitHub Desktop.
Save lucprincen/39c5fc3b877cf41cb559 to your computer and use it in GitHub Desktop.
Simple placeholder fallback for gravity forms
var inputs = {};
jQuery('.gfield input, .gfield textarea' ).each( function(){
var _id = jQuery( this ).attr('id');
var _string = jQuery( this ).val();
inputs[_id] = _string;
});
jQuery('.gfield input, .gfield textarea').click(function(){
var _id = jQuery( this ).attr('id');
var value = jQuery( this ).val();
if( value == inputs[ _id ] ){
jQuery( this ).val('');
}
});
jQuery( '.gfield input, gfield textarea').blur( function(){
var _id = jQuery( this ).attr('id');
var value = jQuery( this ).val();
if( value == '' ){
jQuery( this ).val( inputs[ _id ] );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment