clare2003(忘情火)
但是我表单已经加过一个了方法了
<SCRIPT language="JavaScript">
function mycheck(){
if(document.theform.username.value==""){
alert("请输入用户名!");
document.theform.username.focus();
return false;
}
if(document.theform.psw.value==""){
alert("请输入密码");
document.theform.psw.focus();
return false;
}
if(document.theform.pswc.value==""){
alert("请再次输入密码");
document.theform.pswc.focus();
return false;
}
if(document.theform.e_mail.value==""){
alert("请输入E-mail");
document.theform.e_mail.focus();
return false;
}
if(document.theform.pswc.value!=document.theform.psw.value ){
alert(document.theform.pswc.value);
document.theform.pswc.focus();
return false;
}}
</SCRIPT>
<form action="reghandle.jsp" method="post" name="theform" onSubmit="return mycheck()">
但是我表单已经加过一个了方法了
<SCRIPT language="JavaScript">
function mycheck(){
if(document.theform.username.value==""){
alert("请输入用户名!");
document.theform.username.focus();
return false;
}
if(document.theform.psw.value==""){
alert("请输入密码");
document.theform.psw.focus();
return false;
}
if(document.theform.pswc.value==""){
alert("请再次输入密码");
document.theform.pswc.focus();
return false;
}
if(document.theform.e_mail.value==""){
alert("请输入E-mail");
document.theform.e_mail.focus();
return false;
}
if(document.theform.pswc.value!=document.theform.psw.value ){
alert(document.theform.pswc.value);
document.theform.pswc.focus();
return false;
}}
</SCRIPT>
<form action="reghandle.jsp" method="post" name="theform" onSubmit="return mycheck()">
<%option explicit%>
<html>
<head>
<title>xx</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="../Pub/Css/style.css">
<script language="javascript">
function sub(){
if (form1.Title.value==""){
form1.Title.focus();
alert("信息标题不允许为空!");
return false;
}
</script>
</head>
<body>
<form name="form1" method="post" action="" onsubmit="return sub();">
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan="2" align=center><span class="header">新增信息</span> <hr></td>
</tr>
<tr>
<td width="22%">标题:*</td>
<td width="78%"><input type="text" name="Title" size="68" maxlength="100"></td>
</tr>
<tr>
<td width="22%">副标题:</td>
<td width="78%"><input type="text" name="SubTitle" size="68" maxlength="100"></td>
</tr>
<tr>
<td width="22%">关键字:</td>
<td width="78%"><input type="text" name="Keywords" size="42">(用英文逗号","分割)</td>
</tr>
<tr>
<td colspan="2" align=center><br>* 为必填字段 <hr> </td>
</tr>
<tr>
<td colspan="2" align=center>
<input type="submit" name="submit" value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>
验证代码:
<SCRIPT>
function isEmail(strEmail)
{
if(strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
alert("邮箱格式不正确,请重新输入");
form1.email.value="";
form1.email.focus();
}
</SCRIPT>
<input name=name type=text onblur=isemail(this.value)>现在问题又来。我当没有输入的时候就会一直跳出窗口,我现在是想,有没有代码不用跳出提示窗口,而直接在邮箱文本框后面显示*信箱格式不正确啊
希望高手再次赐教啊~