How to prevent decimal places entered in an input field?

  • Profile Image
    flaviafigueiredo
    Asked on May 29, 2017 at 02:12 PM

    Example:
    Only possible to fill with 1 or 2 or 100 or 1000
    But no possible 1,5   or 6,77

  • Profile Image
    ashwin_d
    Answered on May 29, 2017 at 02:37 PM

    Hello flaviafigueiredo,

    I am not sure if I have understood your question correctly. Do you mean to say that you do not want to show calculation with decimal value in form calculation widget?

    Yes it is possible to achieve your requirement by setting "0" in "Decimal Places in Numerical Results." of your form's "Form Calculation" widget. Please check the screenshot below:

     

    Hope this helps.

    Do get back to us if you meant to ask something else.

    Thank you!

  • Profile Image
    flaviafigueiredo
    Answered on May 29, 2017 at 04:24 PM

    Nope,

    I wanna integral numbers, sorry I type it wrong.

    Example:

    1 day

    Not 1,5 day

  • Profile Image
    Jim_R
    Answered on May 29, 2017 at 05:52 PM

    I'm afraid there's no option for restricting decimal places on input fields. Your alternative is to use Conditions to check the value entered on the field and give a visual warning that the entry is invalid.

    You failed to mention any info about your requirement though, like your Form ID/URL, on what type of field you're hoping to do this, and so on, so I'll just use a Textbox Field as an example, with Numeric Validation enabled.

    Demo form: 71486946416972 (CLONE IT)

    When you try to enter a number with a decimal place (e.g. 1.5, 3.5, and so on), it will conditionally show a Text Field error message.

    Another option is to use Input Masks if you know beforehand how many digits you will be asking. Input Masks can be used with a Textbox.

    Complete guide: Getting-Started-with-the-Basics-of-Input-Masking 

  • Profile Image
    flaviafigueiredo
    Answered on May 29, 2017 at 05:55 PM

    Validation Numeric is not possible to enter 40.5 for example?

  • Profile Image
    Jim_R
    Answered on May 29, 2017 at 06:34 PM

    Numeric Validation on a Textbox allows all sorts of numbers (e.g. integers, whole numbers, floating point numbers, decimals, etc.). And this explains why we had to setup a Condition to conditionally show a custom error message via a Text Field that will prevent them from submitting the form.

    Have you tried the demo form I created? If you did, you will see the following:

    I strongly urge you to check the form or clone it so you can have a closer look. You can also refer to the Input Mask guide I suggested.

  • Profile Image
    flaviafigueiredo
    Answered on May 29, 2017 at 06:39 PM

    how do I make this condition? I dont wanna to copy yours, I wanna understand

  • Profile Image
    Jim_R
    Answered on May 29, 2017 at 06:57 PM

    Sure, for your convenience, I'll include all the things I did, including the condition:

    1. Add a Textbox Field to your form.

    2. Set its Validation option to Numeric.

    3. Add a Text Field that will contain your warning/error message.

    4. Go ahead and setup your Condition. The aim is to SHOW the Text Field warning and HIDE the Submit button.

    Logic:

    IF the Textbox Field CONTAINS a . THEN SHOW the Text Field and HIDE the Submit button

    Related guide: How-to-Show-or-Hide-Fields-Base-on-User-s-Answer