I need to create a pattern for a "text" type input to only allow a number from 0 to a specific max value and at the same time and validate to a specific number of decimal places.
Quick example: Max Value = 300.86 Max Decimal Places = 3
Valid inputs:
0
1
300
300.86
300.85
300.850
300.851
1,200.2
.2
0.3333
Invalid inputs:
-1
301
300.87
300.861
1,30.2
1,.0
,.1
Currently I only know how to validate number of decimal places using this pattern:
^[,0-9]*(.\d{1,{0}})?$
Note: I can't use type=number because I can't use any pattern with that :(
please help
Aucun commentaire:
Enregistrer un commentaire