Expand my Community achievements bar.

SOLVED

Help in Regular Expression

Avatar

Former Community Member

Hi,

Could somebody help me with the regular expression for the following validation of a text field?

1) Total characters in the text field should be limited to 15 (including decimal part if any)

2) The total number of digits after the decimal point (trailing digits) is not more than 5 (however, the decimal part is not mandatory)

The valid values are :

123456789.12345

1123456789.1234

123456789123456

123456789123.10

12345

12345.152

1.12345

The invalid values are :

12345.123456

12345678.1234589

0.1234567

Please Note : Due to some reasons i dont want to go for either a decimal or numeric field. I want to use only a text field.

Thanks,

VJ

1 Accepted Solution

Avatar

Correct answer by
Level 8

Put this in your field's change event:

if (!/^\d{1,9}(\.\d{0,5})?$/.test(xfa.event.newText))

xfa.event.change="";

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Put this in your field's change event:

if (!/^\d{1,9}(\.\d{0,5})?$/.test(xfa.event.newText))

xfa.event.change="";

Kyle