js regexp floating number with leading zero
I need to make an input mask that meets the following requirements:
1255454 - ok
1.54546 - ok
1,0056 - ok
0.6565 - ok
0,0056 - ok
056565 - not ok
ds5asd - not ok
.0565656 - not ok
so far I have found this solution: "/^-?\d*[.,]?\d*$/.test(value)" but it doesn't cover these cases: ".0565656" and "056565"
Ответы (1 шт):
Автор решения: N.K.
→ Ссылка
Предлагаю попробовать такое регулярное выражение:
/^([1-9]|-?\d[.,])\d*$/