<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="" onSubmit="return check(document.form1.textfield.value);">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="提交">
</form>
<SCRIPT LANGUAGE="JavaScript">
function check(inputStr){
iLength = inputStr.length;
for (i = 0; i < iLength; i++){
var aaa=inputStr.charCodeAt(i);
if (!(((64< aaa)&& (aaa< 123 ))||((47< aaa)&& (aaa< 58 )))){
alert("Input error!");
return false ;
}
}
return true ;
}
</SCRIPT></body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="" onSubmit="return check(document.form1.textfield.value);">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="提交">
</form>
<SCRIPT LANGUAGE="JavaScript">
function check(inputStr){
iLength = inputStr.length;
for (i = 0; i < iLength; i++){
var aaa=inputStr.charCodeAt(i);
if (!(((64< aaa)&& (aaa< 123 ))||((47< aaa)&& (aaa< 58 )))){
alert("Input error!");
return false ;
}
}
return true ;
}
</SCRIPT></body>
</html>
<head><title>regExp Test</title>
<script>
function test(){
var reg=/^[A-Za-z0-9]/.test(String.fromCharCode(event.keyCode));
if(!reg) event.keyCode=0;
}
</script>
</head>
<body>
<input type="text" onkeypress="test()">
</body>
</html>