-1

We're trying to restrict a text field to numbers only. Here's what we've tried

  • Add text field
  • Apply input mask (9999999999)

The problem is that if someone does not fully complete the field, the number is erased when they tab into the next field or if they click anywhere outside of that field. It should not matter how many characters they put into the field, it should just restrict the field to a number.

If one only puts one 9 in the field, it restricts the field to 1 number. With the input mask set to ten 9's, you can enter 10 numbers. The problem is that if you do not enter the exact number, it clear the field once it loses focus.

We can do this with jQuery but we're hoping that Gravity has a hidden gem we've missed somewhere?

enter image description here

3
  • As per the screenshot which you have provided, you want user to enter 10 digits. Ideally, clearing the value should be OK if user does not enter complete 10 digits. Please clarify if you want to allow user to input less than 10 digits? Commented Dec 21, 2015 at 14:53
  • @ItsMePN, I have made some edits to clarify. Commented Dec 21, 2015 at 19:15
  • Thanks, I was going to provide same answer which David provided below. I think you shall be good now. Commented Dec 22, 2015 at 4:15

1 Answer 1

4

If you add a question mark before your string of 9s, this will work as desired. It makes the completion optional. It will still enforce a max limit based on the number of 9s you have but there will be no minimum limit.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.