Created
June 29, 2017 05:11
-
-
Save searleb/63e2726132644d2d68cb37f4162cc8cb to your computer and use it in GitHub Desktop.
Function that takes an input string and returns true if the string matches a number between 0 and 9.
This file contains 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
/** | |
* Checks if the value is a number 0-9 or . | |
* @method isNumberOnly | |
* @param {String} value String to test | |
* @return {Boolean} Result of regex test | |
*/ | |
export function isNumberOnly(value) { | |
const regexp = /\d|\./g | |
return regexp.test(value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment