Regex for Currency with specific length in javascript -


i'm using following regex expression currency in input form fields: requirement maximum length of input field 16 digit , after decimal (.) 2 digit. try expression not working. wrong expression.

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

valid

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

invalid

0.00. 99999999999999999.00 999......000 ab999 $99.00 

note:-alphabet , symbol not allowed (only . allow)

you can use regex:

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

regex demo


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -