⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 register.js

📁 JSP购物车(SQLserver版) ================== 简单的JSP电子商务网站购物车 带结算功能,带注册系统 大二时自己编写的,供大家参考学习 功能不是很详尽,美工
💻 JS
字号:
function areaChange(){
	c.o("area").value = c.o("areaId").options[c.o("areaId").selectedIndex].text;
}
function Users(){
	var ok = "&nbsp;<img src=\"images/ok.gif\"/>&nbsp;";
	var err = "&nbsp;<img src=\"images/err.gif\"/>&nbsp;";
	this.reg = function(){
		var a = getTags(c.o("gform"),"textarea");
		var t = getTags(c.o("gform"),"input");
		for(var i=0; i<a.length; i++){
			this.color(a[i],a);
		}
		for(var i=0; i<t.length; i++){
			this.color(t[i],t);
		}
	};

	this.color = function(o,t){
		o.onclick = function(){
			for(var i=0; i<t.length; i++){
				t[i].style.background="none";
			}
			o.style.background="#ffffcc";
		};

	};

	this.display = function(){
		if(c.o("profile").style.display!="block"){
			c.o("profile").style.display="block";
			c.o("chkprofile").innerText="关闭详细资料";
		}else{
			c.o("profile").style.display="none";
			c.o("chkprofile").innerText="显示详细资料";
		}
	}

	this.getNumber = function(){
		var registerKey = c.o("registerKey").value;
		if(!registerKey.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)){
			str = err+"Email地址格式错误!";
			c.o("registerKey_").innerHTML=str;
			return false;
		}
		postSubmit('qwSubmit',true);
	};

	this.subright = function(){
		c.setHtml("subright",err+"出错拉,请看上方右侧的文字提示!!!");
	};
	this.subright_clear = function(){
		c.setHtml("subright","");
	};
	this.regPermission = function(which){
		this.subright_clear();
		var str;
		var userName = c.getValue("userName");
		var password = c.getValue("password");
		var password2 = c.getValue("password2");
		var emailAddress = c.getValue("emailAddress");
		var question = c.getValue("question");
		var answer = c.getValue("answer");
		var penName = c.getValue("penName");
		var homepage = c.getValue("homepage");
		var area = c.getValue("area");
		var city = c.getValue("city");
		var work = c.getValue("work");
		var signatures = c.getHtml("signatures");
		var intro = c.getHtml("intro");
		if(c.getUrl().indexOf("register.jsp")!=-1){
			if((which==0||which==1)&&c.o("registerNumber")){
				var number = c.getValue("registerNumber");
				if(number.length==0){
					c.setHtml("registerNumber_","");
				}
			}
			if(which==0||which==1){
				if(userName.length<3||userName.length>16){
					str = err+"用户名长度应大于2小于16";
					c.setHtml("userName_",str);
					this.subright();
					return false;
				}
				else if(userName.indexOf(" ")!=-1){
					str = err+"用户名不能含有空格";
					c.setHtml("userName_",str);
					this.subright();
					return false;
				}else{
					str = "<a onclick=\"javascript:u.regPost('name');\" style=\"cursor:pointer;\">检测用户名</a>&nbsp;";
					/*str = ok+"<font color=\"#00CC66\">可以注册!</font>";*/
					c.setHtml("userName_",str);
				}
			}
			if(which==0||which==2){
				if(password.length<6||password.length>16){
					str = err+"密码长度应在6到16位之间!!!";
					c.setHtml("password_",str);
					this.subright();
					return false;
				}else{
					str = ok;
					c.setHtml("password_",str);
				}
			}
			if(which==0||which==3){
				if(password2.length==0){
					str = err+"请输入重复密码!";
					c.setHtml("password2_",str);
					this.subright();
					return false;
				}else if(password!=password2){
					str = err+"您两次输入的密码不同,请重新输入!";
					c.setHtml("password2_",str);
					this.subright();
					return false;
				}else{
					str = ok;
					c.setHtml("password2_",str);
				}
			}
		}
		
		if(which==0||which==5){
			if(emailAddress.length==0){
				str = err+"Email地址不能为空!";
				c.setHtml("emailAddress_",str);
				this.subright();
				return false;
			}
			else if(!emailAddress.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)){
				str = err+"Email地址格式错误!";
				c.setHtml("emailAddress_",str);
				this.subright();
				return false;
			}else{
				str = ok+"<a onclick=\"javascript:u.regPost('email');\" style=\"cursor:pointer\">检测Email</a>";
				c.setHtml("emailAddress_",str);
			}
		}
		if(which==0||which==4){
			var s = false;
			var l=document.getElementsByName("sex")  
			for(i=0;i<l.length;i++){  
				if(l[i].checked){s=true;}
			}
			if(!s){
				str = err+"请选择性别";
				c.setHtml("sex_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("sex_",str);
			}
		}
		if(which==0||which==6){
			if(question.length>20){
				str = err+"密码提示问题不能超过20位字符!";
				c.setHtml("question_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("question_",str);
			}
		}
		if(which==0||which==7){
			if(answer.length>20){
				str = err+"密码提示答案不能超过20位字符!";
				c.setHtml("answer_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("answer_",str);
			}
		}
		if(which==0||which==8){
			if(penName.length>30){
				str = err+"您的笔名长度不能超过30位字符!";
				c.setHtml("penName_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("penName_",str);
			}
		}
		if(which==9){
			if(homepage.length>50){
				str = err+"个人主页/Blog网址不能超过50位字符长度!";
				c.setHtml("homepage_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("homepage_",str);
			}
		}
		if(which==0||which==10){
			if(area.length>10){
				str = err+"所在地区不能超过10位字符长度!";
				c.setHtml("area_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("area_",str);
			}
		}
		if(which==0||which==11){
			if(city.length>10){
				str = err+"所在城市不能超过10位字符长度!";
				c.setHtml("city_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("city_",str);
			}
		}
		if(which==0||which==12){
			if(work.length>20){
				str = err+"职业描述不能超过20位字符长度!";
				c.setHtml("work_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("work_",str);
			}
		}
		if(which==0||which==13){
			if(signatures.length>200){
				str = err+"个人签名不能超过200位字符长度!";
				c.setHtml("signatures_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("signatures_",str);
			}
		}
		if(which==0||which==14){
			if(intro.length>200){
				str = err+"个人介绍不能超过200位字符长度!";
				c.setHtml("intro_",str);
				this.subright();
				return false;
			}else{
				str = ok;
				c.setHtml("intro_",str);
			}
		}
		if(which==0||which==0){
			postSubmit('qwSubmit',true);
		}		
		return true;
	};
	
	var action = "";
	this.regPost = function(act){
		action = act;
		var userName = c.getValue("userName");
		var emailAddress = c.getValue("emailAddress");
		if(act=="name"){
			c.setHtml("userName_","正在检测,请稍候...");
			if(userName.length==0){
				alert("用户名不能为空!");
				return false;
			}
		}
		else if(act=="email"){
			c.setHtml("emailAddress_","正在检测,请稍候...");
			if(emailAddress.length==0 || !emailAddress.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) ) {
				alert("Email不能为空,Email地址格式不正确!");
				return false;
			}
		}
		var params = "userName=";
			params += userName;
			params += "&emailAddress=";
			params += emailAddress;
			params += "&act=";
			params += act; /* 0用户名验证 1为Email验证 */
		myxmlhttp = CreateXmlHttpReq(this.RegXmlHttpHandler);
		XmlHttpPOST(myxmlhttp, "/club/users.do", params);
	};
	
	this.RegXmlHttpHandler = function(){
		if (myxmlhttp.readyState !=4 ) {
			return;
		}
		var html = myxmlhttp.responseText;
		if(action=="name"){
			if(html=="true"){
				html = ok+"<font color=\"#00CC66\">恭喜!"+c.getValue("userName")+" 可以注册!</font>";
				doFocus("password");
			}else{
				html = err+" "+c.o("userName").value+" 已被注册!";
				doFocus("userName");
			}
			c.o("userName_").innerHTML=html;
		}else{
			if(html=="true"){
				html = ok+"<font color=\"#00CC66\">恭喜!"+c.getValue("emailAddress")+" 可以注册!</font>";
				doFocus("emailIsOpen");
			}else{
				html = err+" 抱歉,"+c.getValue("emailAddress")+" 已被注册!";
				doFocus("emailAddress");
			}
			c.o("emailAddress_").innerHTML=html;
		}
	};
}
var u = new Users();
function doFocus(id){
	c.o(id).focus();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -