我想让他在点了获取注册码后就对手机号进行验证!并且点了添加后如果没有输入手机号!也先走那个验证!
代码如下:
<%
String sheng = StringUtil.cleannull(request.getParameter("selpro"));
String shi = StringUtil.cleannull(request.getParameter("selcity"));
String xian = StringUtil.cleannull(request.getParameter("seltown"));
String xiang = StringUtil.cleannull(request.getParameter("select"));
String shoujizu = StringUtil.cleannull(request.getParameter("shoujizu"));
String hidden_data = StringUtil.cleannull(request.getParameter("hidden_data")); //得到手机串
JituanManage jtmanage = JituanManageBean.getInstance();
Jituan jituan = jtmanage.getJituan((String) session.getAttribute("jituan_id"));
Set shoujizuSet = jituan.getShoujizu();
System.out.print("********jituan.getJituanId()********="+jituan.getJituanId());
// System.out.print("jituan_id"+(String) session.getAttribute("jituan_id"));
// Set shoujizuSet = jtmanage.getShoujiZu(jituan)
List list = null;
if (!StringUtil.isNullOrNone(request.getParameter("Submit"))) {
String[] tels = hidden_data.split(","); //手机数组
YonghuManage yhmanage = YonghuManageBean.getInstance();
ShoujiZuManage shoujizhManager = ShoujiZuManageBean.getInstance();
ShoujiZu shoujiZuModel=shoujizhManager.getShoujiZu(shoujizu);
for (int i = 0; i < tels.length; i++) {
try {
Yonghu yhu = new Yonghu();
String phone = null;
phone = tels[i];
System.out.println(phone);
yhu.setUsername(phone);
yhu.setMobilephone(phone);
yhu.setZhucetype("jituan");
yhu.setZhuceIP(request.getRemoteAddr());
yhu.setZhucerenID(qiantaiuserbean.getId());
yhu.setZhucetime(new Date());
yhu.setSheng(sheng);
yhu.setShi(shi);
yhu.setXian(xian);
yhu.setXiang(xiang);
yhu.setDelOrzhu("1");
Map map = new HashMap();
map.put("jituan", (String) session.getAttribute("jituan_id"));
map.put("shoujizu", shoujizu);
list = yhmanage.doSave(yhu, map);//保存数据
// System.out.print("i=" + i);
//发送成功信息
SendboxArticle aba = new SendboxArticle();
aba.setJituanID(jituan.getId());
aba.setJituanName(jituan.getJituanName());
aba.setUserName(qiantaiuserbean.getUsername());
aba.setUserID(qiantaiuserbean.getId());
aba.setUserIP(request.getRemoteAddr());
//aba.saveCms(yhu.getMobilephone(), "您已经被注册为" + jituan.getJituanName() + "用户,该条信息免费.");
aba.saveCms(yhu.getMobilephone(), "欢迎您免费试用由爱农信息驿站精心打造的富农短信服务.");
UserLogBean.log("2", (String) session.getAttribute("usertype"), qiantaiuserbean.getUsername(), null, new Date(), request.getRemoteAddr(), "增加用用户:" + yhu.getMobilephone() + "到组:" + request.getParameter("shoujizu") + "-->" + request.getRequestURI(), "添加用户", (String) session.getAttribute("useridd"), (String) session.getAttribute("jituan_id"), (String) session.getAttribute("jituan_name"));
//日志存取
ShoujiZulogManage shujiZulogManager = ShoujiZulogManageBean.getInstance();
ShoujiZulog shoujiZulog = new ShoujiZulog();
shoujiZulog.setAddtime(new Date());
shoujiZulog.setMobilephone(phone);
shoujiZulog.setOperatorID(qiantaiuserbean.getId());
shoujiZulog.setUserIP(request.getRemoteAddr());
shoujiZulog.setOperatorUserName(qiantaiuserbean.getUsername());
shoujiZulog.setUserType("1");
shoujiZulog.setAddOrDelete("1");
shoujiZulog.setJituan_id((String) session.getAttribute("jituan_id"));
// System.out.print("********jituan.getJituanId()********="+jituan.getJituanId());
shoujiZulog.setShoujiZuName(shoujiZuModel.getName());
shoujiZulog.setXinxizhanName(jituan.getJituanName());
try {
shujiZulogManager.saveShoujiZuLog(shoujiZulog);
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
System.out.print("存储日志时出错");
}
}
catch (Exception e) {
e.printStackTrace();
System.out.println("出现错误=====" + e.getMessage());
continue;
}
if (list.size() == 0) {
out.println(StringUtil.getScript("增加成功!", "add_user.jsp"));
}
}
}
%>
<%
IAreaManage _areaManage = (IAreaManage) AreaManageBean.getInstance();
AreaManage _area = new AreaManage();
_areaManage = (IAreaManage) AreaManageBean.getInstance();
List _list = _areaManage.getSheng();
Iterator _iter = _list.iterator();
%>
<script language="javascript">
var oReq;
axo = new ActiveXObject("Microsoft.XMLDOM");
function areaManage(obj, selectName) {
if (obj.value == "")return;
var strA = "";
oReq = new ActiveXObject("Microsoft.XMLHTTP");
oReq.open("POST", "getAreaManageXml.jsp?id=" + obj.value + "", false);
oReq.setRequestHeader("Content-Length", strA.length);
oReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
oReq.send(strA);
axo.loadXML(oReq.responseText);
n1 = axo.selectNodes("/root/id");
n2 = axo.selectNodes("/root/name");
BuildSel(unescape(oReq.responseText), selectName, n1, n2);
}
function BuildSel(str, sel, id, name, scxx)
{
/*
* BuildSel(str,sel)
* 功能:通过str构建Select.
* 参数:str,字符串,由服务端返回的.有特定结构"字符串1,字符串2,字符串3"
* 参数:sel,要构建的Select
*/
sel.options.length = 0;
if (id.length == 0) {
sel.options[sel.options.length] = new Option('', '')
return;
}
var arrstr = new Array();
arrstr = str.split(",");
//开始构建新的Select.
sel.options[sel.options.length] = new Option('请选择---', '');
for (var i = 0; i < id.length; i++) {
sel.options[sel.options.length] = new Option(name(i).text, id(i).text);
}
}
</script>
<html>
<head>
<title>用户管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../inc/style.css" type="text/css">
<style type="text/css">
<!--
.style1 {
color: #FF0000
}
.style2 {
color: #008080;
font-weight: bold;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="2" marginwidth="0" marginheight="0" topmargin="2"
style="background-repeat: repeat-x;">
<center>
<table width="90%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<br>
<table width="92%" border="0" cellspacing="0" cellpadding="0" bgcolor="#D4D4D4">
<tr>
<td height="1" bgcolor="#FFFFFF"></td>
</tr>
<%
if (list != null) {
StringBuffer sb=new StringBuffer();
for(int i=0;i<list.size();i++){
sb.append(list.get(i)+"<br>");
}
%>
<tr>
<td bgcolor="#F8F3D8" style="padding:3px"><div align="center" class="style1"><%=sb.toString()%></div></td>
</tr>
<%}%>
<tr>
<td bgcolor="#006666" style="padding:3px"><div align="center"><strong><font color="#FFFFFF">∷
添加用户 ∷</font></strong></div></td>
</tr>
</table>
<table width="92%" border="0" cellspacing="1" cellpadding="3" bgcolor="#D4D4D4">
<form name="adduser" method="post" action="add_user.jsp" onSubmit="javascript:return check(this);">
<tr bgcolor="#FFFFFF" align="center">
<td width="17%" bgcolor="#FFFFFF"><div align="right"><span class="style1">
* <span class="style2">地 区</span></span><span
class="style2"> </span></div></td>
<td width="49%" align="left"><select name="selpro" style="width:80px" onChange="areaManage(this, document.all.selcity)">
<option value="" selected style="width:100px">省份名称</option>
<%
while (_iter.hasNext()) {
_area = (AreaManage) _iter.next();
%>
<option value="<%=_area.getId()%>"><%=_area.getName()%></option>
<%
}
%>
</select>
<span class="style1">*</span>
<select name="selcity" size=1 style="WIDTH: 85px" onChange="areaManage(this, document.all.seltown)">
<option value="" style="width:100px">城市名称</option>
</select>
<span class="style1">*</span>
<select name="seltown" size=1 style="WIDTH: 85px" onChange="areaManage(this, document.all.select)">
<option value="" style="width:100px">县镇名称</option>
</select>
<span class="style1">*</span>
<select name="select" size=1 style="WIDTH: 85px" onChange=""> <option value="" style="width:100px">乡镇名称</option>
</select></td>
<td width="12%"><span class="style1">* </span>所属手机组</td>
<td width="22%" align="left"><select name="shoujizu">
<option value="">无分组</option>
<%
Iterator it = shoujizuSet.iterator();
while (it.hasNext()) {
ShoujiZu sjz = (ShoujiZu) it.next();
String idd = sjz.getId();
%>
<option value="<%=idd%>"><%=sjz.getName()%></option>
<%
}
%>
</select></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25" bgcolor="#FFFFFF"><span class="style1">* </span><span class="style2">手机号</span></td>
<td colspan="3"><input name="hidden_data" type="hidden" id="hidden_data2" value="<%=request.getParameter("hidden_data")%>" />
<input name="txt_name" type="text" id="txt_name" class="button_D" width="120px"/>
<input name="btn_zcm" type="button" id="btn_zcm" value="获取注册码"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25" bgcolor="#FFFFFF"><span class="style1">* </span><span class="style2">注册码</span></td>
<td colspan="3"><input name="txt_name2" type="text" id="txt_name2" class="button_D" width="120px"/>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td colspan="4"><div align="center">
<input name="Submit" class="button_150" type="submit" value="添加">
</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="4">注意操作步骤:<br>
1、先选择地区、所属手机组<br>
2、在“手机号”
中输入所要添加的手机号<BR>
2、点击按钮“添加”,就会把此手机号加入到右边的手机列表中<BR>
3、如此重复可以添加多个手机号<BR>
4、如果有手机号输入错误,请在右边手机列表中选择错误手机号,然后点击按钮“删除”<BR>
5、确认手机列表中的手机号无误后,点击按钮“添加”,将数据提交保存<br>
所添加用户默认登陆用户名为手机号,密码是<span class="style1">1234</span><br>
<%
// out.print("如果添加成功我们将以短信形式发送给用户如下信息:您已经被注册为" + jituan.getJituanName() + "用户,该条信息免费");
out.print("如果添加成功我们将以短信形式发送给用户如下信息:欢迎您免费试用由爱农信息驿站精心打造的富农短信服务");
%></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</center>
</body>
</html>
<script language="javascript">
<!--
//过滤空格
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
function String.prototype.Ltrim(){return this.replace(/(^\s*)/g, "");}
function String.prototype.Rtrim(){return this.replace(/(\s*$)/g, "");}
function check(e) {
if (e.selpro.value == "")
{
alert("请选择省!");
e.selpro.focus();
return (false);
}
if (e.selcity.value == "")
{
alert("请选择市!");
e.selcity.focus();
return (false);
}
if (e.seltown.value == "")
{
alert("请选择县/区!");
e.seltown.focus();
return (false);
}
if (e.shoujizu.value == "")
{
alert("请选择分组!");
e.shoujizu.focus();
return (false);
}
} </script>
[此贴子已经被作者于2007-6-19 9:13:35编辑过]