jsp高手们注意了,帮忙调试一下程序,行么
- 提问者网友:风月客
- 2021-04-23 13:18
- 五星知识达人网友:执傲
- 2021-04-23 14:42
表单域名不能有“-”要改为下划线“_”
<script language="javascript">
function on_submit(){
if(form1.e_mail.value!=null && form1.e_mail.value!=""){
var i=0;
for(i=0;i<form1.e_mail.value.length;i++){
//alert(form1.e_mail.value.charAt(i));
if(form1.e_mail.value.charAt(i)=='@'){
break;
}
}
if(i==(form1.e_mail.value.length - 1)){
alert("你的输入有误,请重新输入您的邮箱地址!");
form1.e_mail.focus();
return false;
}
}else{
alert("你的输入有误,请重新输入您的邮箱地址!");
form1.e_mail.focus();
return false;
}
}
</script>
<html>
<head>
<title>My JSP 'firstone.jsp' starting page</title>
</head>
<body>
<form method="post" action="" name="form1" onSubmit="return on_submit()">
<center>
<font size="+3" color="blue">注册电子邮箱</font><br><br><br>
电子邮箱:<input type="text" name="e_mail" maxlength=20><br><br><br>
<input type="submit" name="tijiao" value="提交">
</center>
</form>
</body>
</html>
- 1楼网友:春色三分
- 2021-04-23 14:58
if(i==form1.e-mail.value.length)这个改成if(i==form1.e-mail.value.length-1)试试吧