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

王朝vb·作者佚名  2008-05-20
宽屏版  字体: |||超大  

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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有