<script language="javascript">
function regcheck(formct) {
if (formct.id.value !=[a-g]) {
alert('编码非法');
formct.id.focus();
return false;
}
</script><body>
<form action="in.php" method="post" name="form1" target="_blank" onSubmit='return regcheck(this)'>
<input name="id" type="text" id="id" size="10" maxlength="10">
</form>问题为表单id只可输入a-g之间的字母(可输入a,也可输入abcdefg),除外都为非法
function regcheck(formct) {
if (formct.id.value !=[a-g]) {
alert('编码非法');
formct.id.focus();
return false;
}
</script><body>
<form action="in.php" method="post" name="form1" target="_blank" onSubmit='return regcheck(this)'>
<input name="id" type="text" id="id" size="10" maxlength="10">
</form>问题为表单id只可输入a-g之间的字母(可输入a,也可输入abcdefg),除外都为非法
<script language= "javascript ">
function regcheck(formct) {
if (formct.id.value !=[a-g]) {//请修改此行
alert( '编码非法 ');
formct.id.focus();
return false;
}
}
</script> <body>
<form action= "in.php " method= "post " name= "form1 " target= "_blank " onSubmit= 'return regcheck(this) '>
<input name= "id " type= "text " id= "id " size= "10 " maxlength= "10 ">
<input type=submit name=Submit value=录入>
</form>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function regcheck(){
var reg=/^[a-g]+$/i;
var text=document.getElementById("test");
if(!reg.test(text.value)){
alert( '编码非法 ');
text.focus();
return false;
}
return true;
}
</script><body>
<form action= "in.php " method= "post " name= "form1 " target= "_blank " onsubmit="return regcheck()">
<input type= "text" id="test" size= "10 " maxlength= "10 ">
</form>
</body>
</html>
这样?
calmcrime的兼容性更强
zzgzzg00的换个文本框就不行