Skip to content

Instantly share code, notes, and snippets.

@stevensdotb
Last active April 22, 2020 17:14
Show Gist options
  • Save stevensdotb/5bcb74ff0a5a05a3d95a21f391069add to your computer and use it in GitHub Desktop.
Save stevensdotb/5bcb74ff0a5a05a3d95a21f391069add to your computer and use it in GitHub Desktop.
/**
* Avoid non-numeric characters on input text
*/
numberOnly(event) {
const value = event.target.value;
const lastChar = value.length > 0 ? Number(value[value.length - 1]) : 0 ;
const isNaN = char => char !== char;
if ( isNaN(lastChar) ) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment