Created
April 25, 2013 15:30
-
-
Save oliveagle/5460635 to your computer and use it in GitHub Desktop.
javascript: validate number input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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