A regular expression for checking a text field that should contain only decimal numbers and digits

I have a text box for "Area". I need regularexpression to check a text field so that it allows input of decimal places, but no characters. Anyone can help me.

+3
source share
9 answers

Why not try something that is already built into JavaScript: a parseFloat function?

+5
source

This regular expression can check for integers and optional floating point numbers:

[0-9]*\.?[0-9]+

isNaN (), , ( NaN).

+2

, ?

" ?" StackOverflow .

^\d+(\.\d{1,2})?$

, 34. ( )

regex .

Unkwntech , 1,15223,11,00.

:

[-+]?(?:\d(\,?(?>\d{3}[.,]))?)*(?:\.\d*)?

, ,, , 3 ( , . , , , ...

+1

[-+]?(?:\d\,?){0,}(?:\.\d*)?

exapmles, *:

0 *
0.0 *
222.0 *
1,000.00 *
100 000,00 *
-100,000,000,000.12 *
asdf
blah.blah

+1

[.], :

^[-+]?\d*\.?\d*$

( + -)

RegExLib .

0

...

<input> number, , . .

<input id="number" type="number">
Hide result
0

'^[0-9]*$'

-2

, :

/^(?:\d+\.?)|(?:\d*\.\d+)$/
-2

All Articles