Skip to content

Instantly share code, notes, and snippets.

@sewmyheadon
Last active October 20, 2016 14:50
Show Gist options
  • Save sewmyheadon/326cd4138e23408992ac7874f095cf6f to your computer and use it in GitHub Desktop.
Save sewmyheadon/326cd4138e23408992ac7874f095cf6f to your computer and use it in GitHub Desktop.
Hide gravity forms field labels on focus or input
**
* Remove labels from Gravity Forms form fields on focus and input
* Can easily be adapted to forms of any origin
*/
jQuery(function ($) {
jQuery.fn.labelOver = function(overClass) {
return this.each(function(){
var label = jQuery(this);
var f = label.attr('for');
if (f) {
var input = jQuery('#' + f);
this.hide = function() { label.css({ display: "none" }) }
this.show = function() { if (input.val() == '') label.css({ display: "block" }) }
// handlers
input.focus(this.hide); input.blur(this.show);
//label.addClass(overClass).click(function(){ input.focus() }); // Should be able to remove this.
if (input.val() != '') this.hide();
}
})
}
$(document).ready(function() {
// Login
if($('.gfield label').length > 0){ $(".gfield label").labelOver(); }
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment