<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>js检测特殊字符输入 - www.jb200.com </title>
<meta name="generator" content="editplus">
<meta name="author" content="">
<meta name="keywords" content="">
<meta name="description" content="">
<script language="
javascript">
function ischecknumber(){
var numbercard=document.forms[0].num.value;
var numberpattern =/^[a-za-z0-9_]{1,8}$/;
if(!numberpattern.test(numbercard)){
alert("请输入有效的 只能是1-8位数字,字母或数字字母的组合");
document.forms[0].num.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form>
number:<input type="text" name="num" id="num" onblur="ischecknumber()" value=""/>
</form>
</body>
</html>