PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

need to add $ and number formatting to field

  1. I cant get the number fields to include $ sign before it. Also telephone numbers dont format whilst user enters details. price fields, phone numbers, numbers should be in format of $15,000 or (513) 489-6422. So, when someone enters number, it will show to person filling in form

    Once form is submitted the format is correct for telephone number. This should show when user is filling in form.

    Any ideas?

    Posted 11 years ago on Monday April 22, 2013 | Permalink
  2. Check this out for your number field currency question: http://gravitywiz.com/format-field-as-currency/

    For your phone numbers question I'd suggest you try using a single line text field with input masks enabled and select the appropriate input mask.

    Posted 11 years ago on Monday April 22, 2013 | Permalink
  3. I tried pasting the snippet into functions.php and the site wouldn't load. Had to ftp original functions.php file back in.

    Not sure what went wrong. I tried with <?php at the start of snippet and without.

    Am I doing something wrong?

    Posted 11 years ago on Monday April 22, 2013 | Permalink
  4. 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