Vote count:
0
I need to validate some values with javascript on my form before sending it. Accepted only digits and one comma or dot. Comma or dot are optional. For example, values '111', '1.0', '1,0' are valid. And values '1', '.0, '1..' or '1..0' are invalid. So, correct value is a something like float number.
In other words, digits[optional: one comma or dot]digits
is correct string.
I wrote the following regexp:/^([0-9]+)[.|,]{0,1}[0-9]+$/
. I works correct, except for one case - when value is single digit. How can I make my regexp work correctly?
asked 24 secs ago
Aucun commentaire:
Enregistrer un commentaire