0

I'm currently using the following regex expression for currency in my input form fields: my requirement is maximum length of input field is 16 digit and after that decimal (.) then two digit. i try this expression but it not working. something wrong with my expression.

^(\d*\.\d{1,2}|\d+){0,16}$

Valid

 //space- if user leave input box as blank 
0
0.9
9999
9999.0
9999.00
9999999999999999.00

Invalid

0.00.
99999999999999999.00
999......000
AB999
$99.00

Note:-Alphabet and symbol will not allowed (only . will allow)

1
  • basically i have problem with length, if i remove {0,16} then it works. Commented Nov 27, 2014 at 6:04

1 Answer 1

1

You can use this regex:

^\d{0,16}(?:.\d{1,2})?$

Regex Demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.