Created
December 22, 2014 10:24
-
-
Save lucprincen/39c5fc3b877cf41cb559 to your computer and use it in GitHub Desktop.
Simple placeholder fallback for gravity forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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