Skip to content

Instantly share code, notes, and snippets.

@searleb
Created June 29, 2017 05:11
Show Gist options
  • Save searleb/63e2726132644d2d68cb37f4162cc8cb to your computer and use it in GitHub Desktop.
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.
/**
* 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