Created
November 8, 2018 19:50
-
-
Save Kyly/ecaa9f0e5ce0bc6e314b1e474c6c44db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function validateNumber(value) { | |
| let error; | |
| if (!/^('^\\d+$')$/i.test(value)) { | |
| error = 'Only numbers allowed'; | |
| } | |
| return error; | |
| } |
1.1 = false
'1.1' = false
'1a1' = false
1.1 = false
11 = true
/^[0-9]*$/ checks if input only consists of the numbers 0-9 appearing 0 or more times
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.