Skip to content

Instantly share code, notes, and snippets.

@imammubin
Created November 12, 2019 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imammubin/dbb6a2d93469b4d05e48c6e7e42f5476 to your computer and use it in GitHub Desktop.
Save imammubin/dbb6a2d93469b4d05e48c6e7e42f5476 to your computer and use it in GitHub Desktop.
function removeSpaces(string) {
return string.split(' ').join('');
}
function text_number_only(string){
return string.replace(/\D/g,"");
}
function number_only(e){
var key; var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
return true;
else if ((("0123456789").indexOf(keychar) > -1))
return true;
else
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment