<%@page contentType="text/html;charset=UTF-8" %><html>
<head>
<title>ums-register</title>
<link href="${pageContext.request.contextPath}/style/style.css" rel="stylesheet" type="text/css">
</head>
<body background="${pageContext.request.contextPath}/images/body_main.gif" topmargin="0" leftmargin="0">
<jsp:include page="/header.jsp" /><script language="javascript">function checkEmail()
{
var reEmail = /^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;
if (!email.match(reEmail)&&email!="")
{
alert("Email必须符合要求!");
reEmail.focus();
return false;
}
return true;
}
</script><table border="0" cellspacing="0" cellpadding="3" width="100%">
<tr>
<td height="40">
<font color="blue"><b>您的位置:</b></font>
<font color="blue"><b>-> 新邮箱注册</b></font>
</td>
</tr>
</table>
<br>
<form onSubmit="return checkEmail()" method="post" action="${pageContext.request.contextPath}/user/register.do">
<table width="650" border="1" align="center" cellspacing="0" cellpadding="3" bgcolor="#FFFFFF">
<tr>
<td align="center">电子邮件<font color="red">*</font></td>
<td>
<input type="text" size="40" name="email" maxlength="40">
</td>
<tr>
<td align="center">您感兴趣的健康杂志</td>
<td colspan="6">
女人健康中心<input type="checkbox" name="hobbies" value="1">
心理健康中心<input type="checkbox" name="hobbies" value="2">
美容健康中心<input type="checkbox" name="hobbies" value="3">
两性健康中心<input type="checkbox" name="hobbies" value="4">
男人健康中心<input type="checkbox" name="hobbies" value="5">
儿童健康中心<input type="checkbox" name="hobbies" value="6">
素食与减肥健康中心<input type="checkbox" name="hobbies" value="7">
健身健康中心<input type="checkbox" name="hobbies" value="8">
饮食健康中心<input type="checkbox" name="hobbies" value="9">
育儿健康中心<input type="checkbox" name="hobbies" value="10">
妊娠健康中心<input type="checkbox" name="hobbies" value="11">
新闻中心<input type="checkbox" name="hobbies" value="12">
</td>
</tr>
</table>
<br>
<center>
<input type="submit" class="button" value="注 册">
<input type="reset" class="button" value="取 消">
</center>
</form><jsp:include page="/footer.jsp"/>
</body>
</html>
------------------------------------------------------------------------------------------
点"注册"时,没有验证,请高手指点一下
<head>
<title>ums-register</title>
<link href="${pageContext.request.contextPath}/style/style.css" rel="stylesheet" type="text/css">
</head>
<body background="${pageContext.request.contextPath}/images/body_main.gif" topmargin="0" leftmargin="0">
<jsp:include page="/header.jsp" /><script language="javascript">function checkEmail()
{
var reEmail = /^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;
if (!email.match(reEmail)&&email!="")
{
alert("Email必须符合要求!");
reEmail.focus();
return false;
}
return true;
}
</script><table border="0" cellspacing="0" cellpadding="3" width="100%">
<tr>
<td height="40">
<font color="blue"><b>您的位置:</b></font>
<font color="blue"><b>-> 新邮箱注册</b></font>
</td>
</tr>
</table>
<br>
<form onSubmit="return checkEmail()" method="post" action="${pageContext.request.contextPath}/user/register.do">
<table width="650" border="1" align="center" cellspacing="0" cellpadding="3" bgcolor="#FFFFFF">
<tr>
<td align="center">电子邮件<font color="red">*</font></td>
<td>
<input type="text" size="40" name="email" maxlength="40">
</td>
<tr>
<td align="center">您感兴趣的健康杂志</td>
<td colspan="6">
女人健康中心<input type="checkbox" name="hobbies" value="1">
心理健康中心<input type="checkbox" name="hobbies" value="2">
美容健康中心<input type="checkbox" name="hobbies" value="3">
两性健康中心<input type="checkbox" name="hobbies" value="4">
男人健康中心<input type="checkbox" name="hobbies" value="5">
儿童健康中心<input type="checkbox" name="hobbies" value="6">
素食与减肥健康中心<input type="checkbox" name="hobbies" value="7">
健身健康中心<input type="checkbox" name="hobbies" value="8">
饮食健康中心<input type="checkbox" name="hobbies" value="9">
育儿健康中心<input type="checkbox" name="hobbies" value="10">
妊娠健康中心<input type="checkbox" name="hobbies" value="11">
新闻中心<input type="checkbox" name="hobbies" value="12">
</td>
</tr>
</table>
<br>
<center>
<input type="submit" class="button" value="注 册">
<input type="reset" class="button" value="取 消">
</center>
</form><jsp:include page="/footer.jsp"/>
</body>
</html>
------------------------------------------------------------------------------------------
点"注册"时,没有验证,请高手指点一下
改成:
if (email!=""&&!email.test(reEmail))
试试!
也帮你顶一下...
pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>验证Email和数字</title>
</head>
<script language="JavaScript">
function add(){
var y=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
var yj=frm.email.value;
var up = frm.unitPrice.value;
var p =/^[1-9]\d*$/;
if(frm.goodsName.value=="")
{
alert("货物的名字不能为空!!")
}
else if(frm.unitPrice.value=="")
{
alert("单价不能为空!!") }
else if(!p.test(up))
{
alert("货物单价只能为数字!!")
}
else if(!y.test(yj))
{
alert("邮箱地址不对!!")
}
else{
frm.action="goods.do?action=adm";
frm.submit();
alert("验证成功")
}
}
</script>
<body>
<br>
<center>
<form name="frm" method="post">
<TABLE cellSpacing=0 cellPadding=0 width=450 bgColor="#C6D3FF" border=0>
<TBODY>
<TR>
<TD style="FONT-WEIGHT: bolder; FONT-SIZE: small; COLOR: white"
align=middle bgColor=#4682b4 colSpan=2>验证Email和数字</TD></TR>
<TR bgColor="#C6D3FF">
<TD style="WIDTH: 143px"><SPAN id=Label1>货物名字</SPAN></TD>
<td><input type="text" name="goodsName"></td>
</TR>
<TR bgColor="#C6D3FF">
<TD style="WIDTH: 143px"><SPAN id=Label1>邮箱地址</SPAN></TD>
<td><input type="text" name="email"></td>
</TR>
<TR bgColor="#C6D3FF">
<TD style="WIDTH: 143px"><SPAN id=Label1>货物单价</SPAN></TD>
<td><input type="text" name="unitPrice"></td>
</TR>
<TR><td><br></td></TR>
<TR>
<td></td>
<TD align="left">
<p><a href="javascript:add()"><font size=3>验证</font></a></p>
</td>
</TR>
</TBODY>
</TABLE>
</form></center>
</body>
</html>
<%@page contentType="text/html;charset=UTF-8" %> <html>
<head>
<title> ums-register </title>
<link href="${pageContext.request.contextPath}/style/style.css" rel="stylesheet" type="text/css">
</head>
<body background="${pageContext.request.contextPath}/images/body_main.gif" topmargin="0" leftmargin="0">
<jsp:include page="/header.jsp" />
<script language="javascript"> function checkEmail()
{ if(!validmail()){alert("The email's format is invalidate!");
document.profileForm.email.focus(); return;
}
}
function validmail()
{
var mail = document.all.email.value;
var flag = false;
var reg="^([A-Za-z0-9_])+@([A-Za-z0-9_])+([.])([A-Za-z0-9_]+|[A-Za-z0-9_]+[.][A-Za-z0-9_]+)$";
var regExp = new RegExp(reg);
if (regExp.exec(mail)){flag = true;}
return flag;
}
</script> <table border="0" cellspacing="0" cellpadding="3" width="100%">
<tr>
<td height="40">
<font color="blue"> <b> 您的位置: </b> </font>
<font color="blue"> <b> -> 新邮箱注册 </b> </font>
</td>
</tr>
</table>
<br>
<form method="post" action="${pageContext.request.contextPath}/user/register.do">
<table width="650" border="1" align="center" cellspacing="0" cellpadding="3" bgcolor="#FFFFFF">
<tr>
<td align="center"> 电子邮件 <font color="red"> * </font> </td>
<td>
<input type="text" size="40" name="email" maxlength="40">
</td>
<tr>
<td align="center"> 您感兴趣的健康杂志 </td>
<td colspan="6">
女人健康中心 <input type="checkbox" name="hobbies" value="1">
心理健康中心 <input type="checkbox" name="hobbies" value="2">
美容健康中心 <input type="checkbox" name="hobbies" value="3">
两性健康中心 <input type="checkbox" name="hobbies" value="4">
男人健康中心 <input type="checkbox" name="hobbies" value="5">
儿童健康中心 <input type="checkbox" name="hobbies" value="6">
素食与减肥健康中心 <input type="checkbox" name="hobbies" value="7">
健身健康中心 <input type="checkbox" name="hobbies" value="8">
饮食健康中心 <input type="checkbox" name="hobbies" value="9">
育儿健康中心 <input type="checkbox" name="hobbies" value="10">
妊娠健康中心 <input type="checkbox" name="hobbies" value="11">
新闻中心 <input type="checkbox" name="hobbies" value="12">
</td>
</tr>
</table>
<br>
<center>
<input type="button" class="button" value="注 册" onClick="checkEmail()">
<input type="reset" class="button" value="取 消">
</center>
</form> <jsp:include page="/footer.jsp"/>
</body>
</html>