Hi Team,
I have been trying to add the following custom jQuery scripts to my Gravity Forms:
Add default value for Name field(s)
http://www.gravityhelp.com/forums/topic/add-default-value-for-name-fields
Clearing Default Field Values with jQuery
http://www.gravityhelp.com/clearing-default-form-field-values-with-jquery/
Change position of sub-labels on advanced fields
http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields
Request setting to place field descriptions above fields
http://www.gravityhelp.com/forums/topic/request-setting-to-place-field-descriptions-above-fields#post-12697
I have incorporated all of them into a single gravityforms.js file that looks like this:
// clear default field values OnFocus
jQuery(document).ready(function() {
jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
}
});
};
jQuery(".clearit input, .clearit textarea").cleardefault();
});
// Default value for Name fields
jQuery(document).ready(function() {
jQuery("#input_1_2.3").attr("value", "enter your first name");
jQuery("#input_1_2.6").attr("value", "enter your last name");
});
// Move Sub labels ABOVE input fields & select fields
jQuery(document).ready(function() {
jQuery('.ginput_container label').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('.ginput_container input').before(fielddesc); //moves sub label above input fields
jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
jQuery(e).remove();
});
});
// Place field descriptions above fields
jQuery(document).ready(function() {
jQuery('.gfield_description').each(function(i,e){
fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
jQuery(e).siblings('label.gfield_label').after(fielddesc);
jQuery(e).remove();
});
});
Then I have called the file in my header.php file,:
<!-- gravity form jQuery addons -->
<script type="text/javascript" src="<?php bloginfo("template_directory"); ?>/js/gravityform.js"></script>
</head>
As you can see, I have placed this just before </head>, so that it loads after the jQuery script in my theme.
Problem is, THIS DOES NOT WORK on the form.
Am i missing something?
Thanks in advance