How to prevent decimal places entered in an input field?

  • flaviafigueiredo
    Asked on May 29, 2017 at 2:12 PM

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

  • Ashwin JotForm Support
    Replied on May 29, 2017 at 2: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:

    How to prevent decimal places entered in an input field? Image 1 Screenshot 20

     

    Hope this helps.

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

    Thank you!

  • flaviafigueiredo
    Replied on May 29, 2017 at 4:24 PM

    Nope,

    I wanna integral numbers, sorry I type it wrong.

    Example:

    1 day

    Not 1,5 day

  • Support_Management Jotform Support
    Replied on May 29, 2017 at 5: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.

    How to prevent decimal places entered in an input field? Image 1 Screenshot 20

    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 

  • flaviafigueiredo
    Replied on May 29, 2017 at 5:55 PM

    Validation Numeric is not possible to enter 40.5 for example?

  • Support_Management Jotform Support
    Replied on May 29, 2017 at 6: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:

    How to prevent decimal places entered in an input field? Image 1 Screenshot 20

    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.

  • flaviafigueiredo
    Replied on May 29, 2017 at 6:39 PM

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

  • Support_Management Jotform Support
    Replied on May 29, 2017 at 6: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.

    How to prevent decimal places entered in an input field? Image 1 Screenshot 30

    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.

    How to prevent decimal places entered in an input field? Image 2 Screenshot 41

    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