验证数字的有效性,此处为大于0而且小于100的不为空数字为合法
function check(textId) {
var num;
num = document.getElementById(textId).value;
if (num.length == 0 || num.replace(/(^\s*)|(\s*$)/g,"")=="" ) {
alert("\u4e2a\u6570\u7684\u503c\u4e0d\u80fd\u4e3a\u7a7a\uff01");
event.returnValue = false;
}
if (isNaN(num)) {
alert("\u4e2a\u6570\u7684\u503c\u5fc5\u987b\u662f\u6574\u6570\u7684\u6570\u5b57\uff01");
event.returnValue = false;
}
if (parseInt(num) <= 0) {
alert("\u4e2a\u6570\u7684\u503c\u5fc5\u987b\u5927\u4e8e0");
event.returnValue = false;
}
if (parseInt(num) > 100) {
alert("\u4e2a\u6570\u7684\u503c\u5fc5\u987b\u5c0f\u4e8e100");
event.returnValue = false;
}
return true;
}