Skip to content

Instantly share code, notes, and snippets.

@oliveagle
Created April 25, 2013 15:30
Show Gist options
  • Select an option

  • Save oliveagle/5460635 to your computer and use it in GitHub Desktop.

Select an option

Save oliveagle/5460635 to your computer and use it in GitHub Desktop.
javascript: validate number input
function testisNum(object) {
var s = document.getElementById(object.id).value;
if (s !== "") {
if (isNaN(s)) {
alert("请输入数字");
object.value = "";
object.focus();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment