判断表单中添加是否数字的JS与VBS代码
http://www.webjx.com 更新日期:2005-02-24 09:27 出处:网页教学网 作者:
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>
您的评论
·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为