Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Issue with Regex in isNumber.js #26

Open
vijaykumarpendem opened this issue May 19, 2019 · 1 comment
Open

Issue with Regex in isNumber.js #26

vijaykumarpendem opened this issue May 19, 2019 · 1 comment

Comments

@vijaykumarpendem
Copy link

The regex written is /[0-9]+/
It would return true even if there are any other characters in the string.
If the regex is /^[0-9]+$/, it specifies there should not be any characters other than numbers.
Please look into this.

@logicallycorrect
Copy link

/^[0-9]+$/ this will only work for numbers not floating point values. But if you want to include a decimal point in your string then you should use this regex : /^[0-9]\d*(.\d+)?$/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants