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>