I am trying to do something similar only without the "$". I was having the same issue as you and saw someone fixed the code try this
/**
* Format Fields as Currency via jQuery
* http://gravitywiz.com/2012/05/24/format-field-as-currency/
*/
add_filter('gform_pre_render', 'gform_format_money');
function gform_format_money($form) {
if( !wp_script_is( 'gforms_gravityforms' ) )
wp_enqueue_script("gforms_gravityforms", GFCommon::get_base_url() . "/js/gravityforms.js", array("jquery"), GFCommon::$version, true);
$script = '(function($){' .
"$('.gf_money input').each(function(){" .
'$(this).val(gformFormatMoney($(this).val()));' .
'}).change(function(){' .
'$(this).val(gformFormatMoney($(this).val()));' .
'});' .
'})(jQuery);';
GFFormDisplay::add_init_script( $form['id'], 'format_money', GFFormDisplay::ON_PAGE_RENDER, $script );
return $form;
}
Posted 11 years ago on Monday May 6, 2013 |
Permalink