站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题判断表单中添加是否数字的JS与VBS代码

判断表单中添加是否数字的JS与VBS代码

摘要: 判断表单中添加是否数字的JS与VBS代码


1.用javascript判断 [isNaN()]
JS代码:
<script language="javascript">
function check(formname){
if (isNaN(formname.price.value)){
alert('请输入数字');
formname.price.focus();
return false;
}
alert('是数字,通过');
return true;
}
</script>

调用:
<form name="form1" method="post" action="" onsubmit="check(this)">
<input type="text" name="price">
<input type="submit" name="Submit" value="提交">
</form>

2.用VBscript判断[isnumeric()]
跟上面的类似,用isnumeric()函数即可
<script language=vbscript>
sub isnum(param)
if not isnumeric(param) then
msgbox("请输入数字")
end if
end sub
</script>

</td> </tr> <tr> <td vAlign=top align=left height="100%">
↑返回目录
前一篇: 使用Javascript制作行间颜色间隔
后一篇: 为网页添加浮动广告