You are viewing limited content. For full access, please sign in.

Question

Question

Any way to enter decimals in a number field in Forms?

asked on August 28, 2014

Hi,

 

I'm curious if there's a way to configure the "number" field in Forms to accept decimal numbers.  In this case, I have a "Number of Years?" field after a "current address" field, where I would expect people would like to enter values like: "1.5, 2.75".  I'm also trying to associate a Field Rule to show a "previous address" field if the value entered is less than 2.

 

I thought a viable workaround would be to use a Single Line field with the regex "\d*", but the Single Line doesn't allow for the "less than" logic in Field Rules that the Number field allows.

 

Thoughts?

0 0

Answer

SELECTED ANSWER
replied on August 28, 2014

A couple ideas:

 

  1. Use single line fields and write JavaScript for the show/hide behavior.
  2. Use  currency fields, hide the currency symbol, and use field rules.

 

If you go the second route, be aware that the field rule will evaluate the value as you're entering it, so the hidden field might briefly flash. For example, if you show a field when the value is less than 2, if you enter 10, you'll see the field after you enter 1.

 

 

0 0

Replies

replied on September 2, 2014

Hi Eric, 

 

If your question has been answered, please let us know by clicking the "This answered my question" button on the appropriate response.

 

If you still need assistance with this matter, just update this thread. Thanks!

0 0
replied on October 13, 2015

Trying to enter decimals in a number field in a form but receive invalid input error.  Is there any JS to fix this?  This form is live and has 4 other forms attached to it with the field information passing to each so would rather not replace it with a single line etc.  We use this for grades and while we were fine with a rounded number, it is not completely accurate and management wants this changed.

 

Thanks

Shalini

0 0
replied on October 13, 2015

If you give your number field a CSS class name like decimal, then you can use the following JavaScript

$('.decimal input').attr('step', 'any');

See this page for more information about using step="any"

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.