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.

Number fields (please enter a valid number error) set min to 0.1, ex. 1.2, 2.7

  1. Is there anyway to just disable number validation checking or to make this work?

    I have people entering orders that need to be down to the one tenth. I set the min value to 0.1 this worked when I set it to 0.01 for 1/100th entries i.e. 1.80 but it does not work upon setting it to 0.1 and entering 1.8.. only if I enter full 100ths even with the min setting at 0.1

    Posted 13 years ago on Friday December 2, 2011 | Permalink
  2. I am not sure I understand your issue, but the min value setting should be used to specify the minimum allowed number, not the minimum decimal digits. There is no built-in way to enforce users to enter only one decimal digit. If you have PHP experience, you can use the gform_field_validation hook and a few lines of PHP code to perform a custom validation. The following page has information about that hook.
    http://www.gravityhelp.com/documentation/page/Gform_field_validation

    Posted 13 years ago on Friday December 2, 2011 | Permalink
  3. To add to what Alex said, there is also a tutorial on how to use the gform_validation to create custom validation here:

    http://www.gravityhelp.com/documentation/page/Using_the_Gravity_Forms_%22gform_validation%22_Hook

    Posted 13 years ago on Friday December 2, 2011 | Permalink
  4. I don't want to make them enter anything, that is my problem..

    I have users entering 1.5 and it is giving a please enter a valid number error. Will that custom validation just allow me to disable it all together?

    Posted 13 years ago on Saturday December 3, 2011 | Permalink
  5. To make things even more clear, before going into all this. I just used the default number field settings no range.. entering 1.5 generates a "Please enter a valid number"

    please explain how and why 1.5 is not a valid number

    Posted 13 years ago on Saturday December 3, 2011 | Permalink
  6. upon diving into the code I have a strong feeling "is_numeric" is somehow wrong and not understanding decimal point numbers..

    Posted 13 years ago on Saturday December 3, 2011 | Permalink
  7. Okay I fixed it myself..

    you have:

    public static function is_numeric($value){
    return preg_match("/^(-?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})?)$/", $value) || preg_match("/^(-?[0-9]{1,3}(?:\.?[0-9]{3})*(?:,[0-9]{2})?)$/", $value);

    in common.php

    YOU NEED:
    public static function is_numeric($value){
    return preg_match("/^(-?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{1,2})?)$/", $value) || preg_match("/^(-?[0-9]{1,3}(?:\.?[0-9]{3})*(?:,[0-9]{1,2})?)$/", $value);

    The difference is not hard coding to 2 digits..

    Posted 13 years ago on Saturday December 3, 2011 | Permalink