Hello,
Have a weird one here. What would be the simplest way to set up a number field on a form so that it will only accept even numbers?
Thanks!
Question
Question
Forms - Force user to put an even number into a number field
Answer
You can use a regular expression with a single line field and do:
^\d*[02468]$
This is what I ended up going with. I didn't include that this field in question is in a table, and is involved in calculations. So what I did was add a text field with the regular expression you mentioned. Then I took my number field that I already had and gave it a formula to copy whatever was input in the text field for that same row, and also made this number field hidden. So I can continue to use my original number field in my calculations, but use the text field to get the input with the constraint on it.
Thanks!
Glad it worked for you! You can also put the variable in a VALUE() formula to do calculations on single line fields
For example:
=SUM(VALUE(SingleLine))
Much nicer than my suggestion. Thank you!
Replies
I figured out a way, but I'm not sure it is the simplest.
I have a field for the enter an even number.
Another field that divides that number by 2.
A field that is a text field that is the divided by 2 number.
And an HTML field that says, "Please enter an even number" when the field divided by 2 has a "." in it.
But I hide always and save data for DivideNumber by 2 and Divideby2Result.