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.

Unable to use comma in number field range

  1. Ketiga
    Member

    Hi,

    1. It's not possible for me to use a comma in the min/max range fields when using a number field.
    If I do, the range is ignored.

    2. I would also like to force two decimals behind my comma, how do I accomplish this?

    I have the correct dropdown with format 9.999,99 selected already but right now the number '2' is just saved to the database as '2' when I need it to be saved to my datbase as '2.00'

    Posted 11 years ago on Wednesday July 4, 2012 | Permalink
  2. David Peralty

    Hi there,

    1. No it is not possible to use a comma in the min/max range. These only accept whole numbers.

    2. I created the following hook/function to make sure it is forced to two decimal places at all times

    add_filter("gform_pre_submission_filter", "adddecimals");
    function adddecimals($form){
    
    $_POST["input_20"] =  number_format($_POST["input_20"],2);
    
    return $form;
    
    }

    You will want to change the input field number to your own. Hope this helps

    Posted 11 years ago on Wednesday July 4, 2012 | Permalink
  3. Ketiga
    Member

    Thank you so much for the quick reply.

    Got it to work with some slight adjustments:

    add_filter("gform_pre_submission_filter", "adddecimals");
    function adddecimals($form){
    
    $_POST["input_5"] =  number_format($_POST["input_5"],2,',','.');
    
    return $form;
    
    }

    Thanks again!

    Posted 11 years ago on Wednesday July 4, 2012 | Permalink
  4. David Peralty

    Glad to hear it.

    Posted 11 years ago on Wednesday July 4, 2012 | Permalink

This topic has been resolved and has been closed to new replies.