<script language="vbscript"> function bc() Dim Str, StrLen, Max str=document.frm.test.value if isnumeric(str)=false and str<>"" then msgbox("请输入数字") document.frm.test.focus() document.frm.test.select() exit function end ifStrLen=Len(str)For i=1 to 8-StrLen Str = "0" & Str Next document.frm.test.value=str end function </script><form name=frm> <input name=test maxlength=8 onblur="vbscript:bc()"> </form>
function bc()
Dim Str, StrLen, Max
str=document.frm.test.value
if isnumeric(str)=false and str<>"" then
msgbox("请输入数字")
document.frm.test.focus()
document.frm.test.select()
exit function
end ifStrLen=Len(str)For i=1 to 8-StrLen
Str = "0" & Str
Next
document.frm.test.value=str
end function
</script><form name=frm>
<input name=test maxlength=8 onblur="vbscript:bc()">
</form>