- Rongsen.Com.Cn 版权所有 2008-2010 京ICP备08007000号 京公海网安备11010802026356号 朝阳网安编号:110105199号
- 北京黑客防线网安工作室-黑客防线网安服务器维护基地为您提供专业的
服务器维护
,企业网站维护
,网站维护
服务 - (建议采用1024×768分辨率,以达到最佳视觉效果) Powered by 黑客防线网安 ©2009-2010 www.rongsen.com.cn
作者:黑客防线网安网站维护基地 来源:黑客防线网安网站维护基地 浏览次数:0 |
1<%@page language="java" contentType="text/html;charset=GBK"%> 2<script language="javascript" type="text/javascript"> 3<!-- 4/**//**Ajax 开始 by Alpha 2005-12-31*/ 5 6 var http = getHTTPObject(); 7 8 function handleHttpResponse(){ 9 if(http.readyState == 4){ 10 if(http.status == 200){ 11 var xmlDocument = http.responseXML; 12 if(http.responseText!=""){ 13 document.getElementById("showStr").style.display = ""; 14 document.getElementById("userName").style.background= "#FF0000"; 15 document.getElementById("showStr").innerText = http.responseText; 16 }else{ 17 document.getElementById("userName").style.background= "#FFFFFF"; 18 document.getElementById("showStr").style.display = "none"; 19 } 20 21 } 22 else{ 23 alert("你所请求的页面发生异常,可能会影响你浏览该页的信息!"); 24 alert(http.status); 25 } 26 } 27 } 28 29 function handleHttpResponse1(){ 30 if(http.readyState == 4){ 31 if(http.status == 200){ 32 var xmlDocument = http.responseXML; 33 if(http.responseText!=""){ 34 document.getElementById("comNmStr").style.display = ""; 35 document.getElementById("comNm").style.background= "#FF0000"; 36 document.getElementById("comNmStr").innerText = http.responseText; 37 }else{ 38 document.getElementById("comNm").style.background= "#FFFFFF"; 39 document.getElementById("comNmStr").style.display = "none"; 40 } 41 42 } 43 else{ 44 alert("你所请求的页面发生异常,可能会影响你浏览该页的信息!"); 45 alert(http.status); 46 } 47 } 48 } 49 50 function chkUser(){ 51 var url = "/chkUserAndCom"; 52 var name = document.getElementById("userName").value; 53 url += ("&userName="+name+"&oprate=chkUser"); 54 http.open("GET",url,true); 55 http.onreadystatechange = handleHttpResponse; 56 http.send(null); 57 return ; 58 } 59 function chkComNm(){ 60 var url = "/chkUserAndCom"; 61 var name = document.getElementById("comNm").value; 62 url += ("&comName="+name+"&oprate=chkCom"); 63 http.open("GET",url,true); 64 http.onreadystatechange = handleHttpResponse1; 65 http.send(null); 66 return ; 67 } 68 69 //该函数可以创建我们需要的XMLHttpRequest对象 70 function getHTTPObject(){ 71 var xmlhttp = false; 72 if(window.XMLHttpRequest){ 73 xmlhttp = new XMLHttpRequest(); 74 if(xmlhttp.overrideMimeType){ 75 xmlhttp.overrideMimeType('text/xml'); 76 } 77 } 78 else{ 79 try{ 80 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 81 }catch(e){ 82 try{ 83 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 84 }catch(E){ 85 xmlhttp = false; 86 } 87 } 88 } 89 return xmlhttp; 90 } 91/**//**Ajax 结束*/ 92 93//检测表单 94function chkpassword() 95{ 96 var m=document.form1; 97 if(len(m.password.value) > 20 || len(m.password.value) < 5 || !isStr(m.password.value)) 98 { 99 document.getElementById("passwordStr").style.display = ""; 100 document.getElementById("password").style.background= "#FF0000"; 101 document.getElementById("passwordStr").innerText = "对不起,密码必须为英文字母、数字或下划线,长度为5~20!"; 102 } 103 else 104 { 105 document.getElementById("password").style.background= "#FFFFFF"; 106 document.getElementById("passwordStr").style.display = "none"; 107 } 108} 109 110function chkconfirmPassword() 111{ 112 var m=document.form1; 113 if (m.password.value != m.confirmPassword.value) 114 { 115 document.getElementById("confirmPasswordStr").style.display = ""; 116 document.getElementById("confirmPassword").style.background= "#FF0000"; 117 document.getElementById("confirmPasswordStr").innerText = "对不起,密码与重复密码不一致!"; 118 } 119 else 120 { 121 document.getElementById("confirmPassword").style.background= "#FFFFFF"; 122 document.getElementById("confirmPasswordStr").style.display = "none"; 123 } 124} 125 126function checkfield() 127{ 128 var m=document.form1; 129 if(m.userName.value.length==0) 130 { 131 alert("对不起,用户名必须为英文字母、数字或下划线,长度为5~20。"); 132 m.userName.focus(); 133 return false; 134 } 135 if(m.password.value.length==0) 136 { 137 alert("对不起,密码必须为英文字母、数字或下划线,长度为5~20。"); 138 m.password.focus(); 139 return false; 140 } 141 if (m.password.value != m.confirmPassword.value) 142 { 143 alert("对不起,密码与重复密码不一致!"); 144 m.confirmPassword.focus(); 145 return false; 146 } 147 if(m.comNm.value.length==0) 148 { 149 alert("对不起,企业名称不能为空!!"); 150 m.comNm.focus(); 151 return false; 152 } 153 m.submit(); 154} 155 156//--> 157</script> 158<body topmargin="0"> 159<form name="form1" method="post" action="/Control?act=Register"> 160<table width="100%"> 161 <tr><td align="center"> <H2>Ajax 演示程序</H1></td></tr> 162 <tr><td align="center"> ------ 企业注册 By Alpha</td></tr> 163</table> 164 165<HR> 166 <table width="400" border="0" cellpadding="1" cellspacing="1" align="center" > 167 <tr> 168 <td><font color="red">*</font></td> 169 <td>用户帐号:</td> 170 <td> 171 <input type="text" name="userName" maxlength="20" style="background:#FFFFFF" onBlur="chkUser()" value=""/> 172 <div id="showStr" style="background-color:#FF9900;display:none"></div> 173 </td> 174 </tr> 175 <tr> 176 <td><font color="red">*</font></td> 177 <td>企业名称:</td> 178 <td> 179 <input type="text" name="comNm" maxlength="100" style="background:#FFFFFF" onBlur="chkComNm()" value=""/> 180 <div id="comNmStr" style="background-color:#FF9900;display:none"></div> 181 182 </td> 183 </tr> 184 <tr> 185 <td><font color="red">*</font></td> 186 <td>用户密码:</td> 187 <td><input type="password" name="password" maxlength="20" style="background:#FFFFFF" onBlur="chkpassword()"/> 188 <div id="passwordStr" style="background-color:#FF9900;display:none"></div> 189 </td> 190 </tr> 191 <tr> 192 <td><font color="red">*</font></td> 193 <td>确认密码:</td> 194 <td><input type="password" name="confirmPassword" maxlength="20" style="background:#FFFFFF" onBlur="chkconfirmPassword()"/> 195 <div id="confirmPasswordStr" style="background-color:#FF9900;display:none"></div> 196 </td> 197 </tr> 198 </table> 199 200 <div align="center"> 201 <input type="button" name="ok" value=" 确 定 " onclick="checkfield()"> 202 203 <input type="reset" name="reset" value=" 取 消 "> 204 </div> 205 206</form> 207</body> 208</html> |
1/**//* 2 * Created on 2005-12-31 3 * 4 * TODO To change the template for this generated file go to 5 * Window - Preferences - Java - Code Style - Code Templates 6 */ 7package com.event; 8 9import javax.servlet.ServletException; 10import javax.servlet.http.HttpServletRequest; 11import javax.servlet.http.HttpServletResponse; 12 13import com.beans.EBaseInfo; 14 15/** *//** 16 * @author Alpha 2005-12-31 17 * 18 * <P>Ajax 演示---企业注册时检查企业用户名和企业名称</P> 19 * 20 * TODO To change the template for this generated type comment go to 21 * Window - Preferences - Java - Code Style - Code Templates 22 */ 23public class CheckUserAndComNm { 24 private String msgStr = ""; 25 protected void doGet(HttpServletRequest request,HttpServletResponse response) 26 throws ServletException 27 { 28 29 EComBaseInfo info=new EComBaseInfo(); 30 String oprate=request.getParameter("oprate")).trim(); 31 String userName=request.getParameter("userName"); 32 String passWord=request.getParameter("password"); 33 String comName=request.getParameter("comName"); 34 35 try 36 { 37 if(oprate.equals("chkUser")) 38 { 39 response.setContentType("text/html;charset=GB2312"); 40 if(userName.length()<5||userName.length()>20) 41 { 42 msgStr = "对不起,用户名必须为字母、数字或下划线,长度为5-20个字符!"; 43 } 44 else 45 { 46 boolean bTmp=info.findUser(userName); //找查数据库中有无该用户名 47 if(bTmp) 48 msgStr ="对不起,此用户名已经存在,请更换用户名注册!"; 49 else 50 msgStr =""; 51 } 52 response.getWriter().write(msgStr); 53 } 54 else if(oprate.equals("chkCom")) 55 { 56 response.setContentType("text/html;charset=GB2312"); 57 if(comName.length()<6||comName.length()>100) 58 { 59 msgStr = "对不起,公司名称长度为6-100个字符(不包括字符内的空格)!"; 60 } 61 else 62 { 63 boolean bTmp=info.findCom(comName); //找查数据库中有无该企业名 64 if(bTmp) 65 msgStr ="对不起,此企业名称已经存在,请更换企业名称注册!"; 66 else 67 msgStr =""; 68 } 69 response.getWriter().write(msgStr); 70 71 } 72 } 73 catch(Exception ex) 74 { 75 } 76 finally 77 { 78 request.setAttribute("url",url); 79 } 80 } 81 82 protected void doPost(HttpServletRequest request,HttpServletResponse response) 83 throws ServletException 84 { 85 doGet(request,response); 86 } 87} 88 |
我要申请本站:N点 | 黑客防线官网 | |
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479 |