Skip to content

Instantly share code, notes, and snippets.

@renie
Last active December 20, 2015 23:48
Show Gist options
  • Save renie/6214708 to your computer and use it in GitHub Desktop.
Save renie/6214708 to your computer and use it in GitHub Desktop.
Just numbers on html input
onkeyup="this.value = isNaN(this.value.substr(this.value.length-1>0?this.value.length-1:0, this.value.length-1>1?this.value.length-1:1))?(this.value.length<2?"":this.value.substr(0,this.value.length-1)).replace(/\s+/g,""):this.value.replace(/\s+/g,"")"
onkeypress="this.value = isNaN(this.value.substr(this.value.length-1>0?this.value.length-1:0, this.value.length-1>1?this.value.length-1:1))?(this.value.length<2?"":this.value.substr(0,this.value.length-1)).replace(/\s+/g,""):this.value.replace(/\s+/g,"")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment