I want that the text field only accept numeric values and spaces.
What is regular expression for this?
I was trying with \\d+$
Thanks
This should work.
/^[0-9\s]*$/
You're going to want to use [0-9 ]+
^
for the begining of string.
[\d ]*
for any combination of this symbols.
$
for end of string.
^[\d ]*$
If you want to match only the numbers, use:
(\b\d+)/g
or(\b[0-9]+)/g
where:
\b
will match borders
\d
or [0-9]
match numbers
+
will match 1 or more times \d
(or [0-9]
)
/g
turns on global mode, to match the regex many times
This one should work :
[0-9 ]+