Expand my Community achievements bar.

Dont allow user to enter more than specified number of digits/chars?

Avatar

Level 8

Hello

First case: I have placed a TEXT field on the form. Now i want to put the below validation,

1) User has to enter only numbers (no decimals)

2) Only 10 digits

If not i need to

1) Alert app.alert

2) Make the field either CLEARIng or considering & resetting only the first 10 digits (if user entered more than 10 digits)

2nd case: Same as above, a TEXT field, but, the data is with a DECIMAL notation, the allowed lenghts are as

2 digits as prefix to decimal

2 digits as suffix to decimal position

example, 35.88

Pls. let me knw the Java Script for these 2 cases or do you suggest me PATTERN validation if so, can i CLEAR or reset  and if so, pls. let me know under which TAB(Display / Edit / Data) i need to put the PATTERN validation?

1 Reply

Avatar

Level 7

Firstly if you are only allowing numbers then the field should be a numeric field not a text field. You can use patterns to allow only whole numbers or to have 2 digits on either side of the decimal.

In regards to the number of digits you can use the len function to determine the length of the data and if it is too long give a message or clear it.