为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

js验证信息(JS authentication information)

2018-02-11 20页 doc 45KB 19阅读

用户头像

is_321575

暂无简介

举报
js验证信息(JS authentication information)js验证信息(JS authentication information) js验证信息(JS authentication information) / / 确认密码检测 function pass _ u.a. () { were u _ pass = document.getelementbyid (u _ pass').value; was pass _ re = document.getelementbyid (u _ pass _ u.a.).value; if (d _ pass! = pass _ ...
js验证信息(JS authentication information)
js验证信息(JS authentication information) js验证信息(JS authentication information) / / 确认密码检测 function pass _ u.a. () { were u _ pass = document.getelementbyid (u _ pass').value; was pass _ re = document.getelementbyid (u _ pass _ u.a.).value; if (d _ pass! = pass _ u.a.) { document.getelementbyid (pass _ u.a. _ u.a.).innerhtml = 'x'; document.getelementbyid (pass _ u.a. _ u.a. _ m).innerhtml = < span class = msg > 两次密码不一致, 请重新输入 < / span > '; return false; } / / 密码是否为空检测 function password () { were u _ pass = document.getelementbyid (u _ pass').value; if (d _ pass = = "" | | d _ pass.length < 6) { document.getelementbyid (pass _ u.a.).innerhtml = 'x'; document.getelementbyid (pass _ u.a. _ m).innerhtml = < span class = msg 密码长度不足6位数 > < / span > '; return false; } else { document.getelementbyid (pass _ u.a.).innerhtml = ? '; document.getelementbyid (pass _ u.a. _ m).innerhtml = < span class = msg2 > 填写正确 < / span > '; return true; } } was req = false; try { req = new activexobject ("msxml2.xmlhttp"); } catch (e) { try { req = new activexobject ("microsoft.xmlhttp"); } catch (e2) { req = false; } } if (! req & typeof xmlhttprequest! = undefined ') { req = new xmlhttprequest (); } / / 发送请求 参数依次为 传送方式 (get、post), 处理网址 (url), 同步 (true, false) function send (medhot, url, tb, action, msgfalse, msgtrue) { was medhot = medhot; was url = url; tb was = tb; req.open (medhot, url, tb); req.onreadystatechange = function () {requestprocessor (action, msgfalse, msgtrue)}; if (! xmlhttprequeststate (req)) { req.send (); } else { / / document.write ("对不起, 请稍等...") } } / / 验证xmlhttp状态是否正在请求 function xmlhttprequeststate (req) { switch (req.readystate) { case 1,2,3: return true; break; default: return false; break; } } / / onreadystatechange 请求处理机制 requestprocessor # # # # # # # # # function requestprocessor (action, msgfalse, msgtrue) { was chk = "false"; if (req.readystate = = 4) / / 等于4示请求 { / / 返回状态 state 等于 200 表示一切顺利 if (req.status = = 200) { / / 如果responsetext不为空, Explain information returned Var text = req.responseText; If (text = = ') { If (text== 'true') { InnerHtml (action+, _alert, msgFalse); ChangeClass ("action+", "_alert", "chk_false"); }else{ InnerHtml (action+, _alert, msgTrue); ChangeClass ("action+", "_alert", "chk_true"); Chk = "true""; } }else{ InnerHtml ("user_alert", "re choice"); } }else { InnerHtml ("user_alert", req.status) //document.write (req.status) } } Document.getElementById (action+ "_chk").Value = chk; / / Alert (Action + "" + chk + "," + document.getElementById (action+ _chk).Value); } The /*DIV property of the innerHTML function ##########*/ As the object parameters / / ID content Function InnerHtml (objectId, objectContent) { Document.getElementById (objectId).InnerHTML = objectContent; } Modify the object / / class attribute Function ChangeClass (objectId, classname) { Document.getElementById (objectId).ClassName = classname; } To determine whether the string contains Chinese / / Function checkIsChinese (STR) { / / if the value is null, by checking //var = pattern / ^ ([/u4E00-/u9FA5]|[/uFE30-/uFFA0]) *$/gi; Var = pattern / /u4e00-/u9fa5]/; If (pattern.test (STR)) Return true; Else Return false; } / * character length Property, in turn, is object ID, which requires character length and error hints * / Function ChkLength (objectId, strLength) { LengthChk=false; ObjectAlert=objectId+ "_alert"" Str=document.getElementById (objectId).Value; If (str.length < strLength) { LengthChk=true; } Return lengthChk; } Verify password length * / / * character Function ChkPassword (objectId, strLength) { ChkPassword=true; If (ChkLength (objectId, strLength)) { InnerHtml (objectAlert, password no less than 6 bit characters); ChkPassword = false; }else{ InnerHtml (objectAlert, password validation); } ChangeClass (objectAlert, chk_, +chkPassword); If (document.getElementById (objectId+, 2).Value! = "") passwordflag (objectid + "2", objectid) return chkpassword; } / * 密码确认 * / / * 参数依次为 确认密码, 密码 * / function passwordflag (pass2, pass) { was chkpasswordflag = true; psd = document.getelementbyid (pass).value; psd2 = document.getelementbyid (pass2).value; psd2alert = pass2 + "_ alert" if (psd = = psd2) { innerhtml (psd2alert, "确认密码正确"); } else { innerhtml (psd2alert, "确认密码不正确"); chkpasswordflag = false; } if (chklength (pass2, 6)) { innerhtml (psd2alert, "密码不少于6位字符"); chkpasswordflag = false; } changeclass (psd2alert, "chk _" + chkpasswordflag); return chkpasswordflag; } / / 是否包含指定字的验证 / / 参数依次为 需要验证的字符串, 字符 用, 隔开 function chkchar (str, char) { was chk = false; was chararray = char.split (","); was chararrayubound = chararray.length; for (i = 0; i < = chararrayubound; i + +) { if (str.indexof (chararray [in]). = - 1) { chk = true; break; } } return chk; } / / 用户名验证 function chkuser (objectid) { chkuser = true; user = document.getelementbyid (objectid).value; objectalert = objectid + "_ alert"; was reg = ^ [0 - 9a - za z] {} $4.20 /; if (! reg.test (user)) { innerhtml (objectalert, "只能是4 - 20位0 - 9和a - z的组合 区分大小写"); changeclass (objectalert, "chk _ folds") chkuser = false; } else { innerhtml (objectalert, "用户名正确"); } changeclass (objectalert, "chk _" + chkuser); return chkuser; } / * 判断邮箱是否正确 * / function isemail (objectid) { was chkemail = true; was mail = document.getelementbyid (objectid).value; objectalert = objectid + "_ alert" was reg = ^ [0 - 9a - za z _ / -] + @ [0 - 9a - za - z] + (/. [a - za - z] +) {1} $/; if (! reg.test (mail) { innerhtml (objectalert, "邮箱地址格式错误"); chkemail = false; } else { innerhtml (objectalert, "邮箱地址格式正确") } changeclass (objectid + "_ alert", "chk _" + chkemail) return chkemail; } / / 邮箱验证结束 / /验证码验证 ChkImg(objectid)功能 { chkimg =真; img =文件。getElementById(objectid值); objectalert = ObjectId +“_alert”; VaR reg = / ^ [0-9] +美元/; 如果(~区域试验(IMG))。 { innerHTML(objectalert,“只能是数字”); ChangeClass(objectalert,“chk_false”) chkimg = false; } 其他的 { innerHTML(objectalert,“验证码格式正确”); } ChangeClass(objectalert,“chk_”+ chkimg); 返回chkimg; } / /判断用户名是否存在 功能userexist(objectid) { 如果(Chkuser(objectid)){ 用户=文件。getElementById(objectid值); 发送(“得到”,“yp.htm,DDC = check_yp &用户=”+用户,真的, 用户名已经存在objectid,“”,“”)用户名可以正常使用; } } / /判断验证码是否正确 ChkCode(objectid)功能 { 如果(ChkImg(objectid)){ VaR img =文件。getElementById(objectid值); 发送(“得到”,“yp.htm,DDC = check_img和img =”+ IMG,真 的,验证码不正确objectid,“”,“”)验证码正确; } } / /判断提示问题的是否填写; ChkAnswer(objectid)功能 { 无功chkanswer = false; 无功objectalert = ObjectId +“_alert”; VaR的回答=文件。getElementById(objectid值); 如果(ChkLength(ObjectId,3)) { innerHTML(objectalert,“提示答案不小于3位字符”); } 其他的 { 如果(~ChkChar(回答,”,,,“)) { innerHTML(objectalert,“提示答案正确”); chkanswer =真; } 其他的 { innerHTML(objectalert,“不能含有特殊字符/“/”/“/”/“/”/“/”); } } ChangeClass(objectalert,“chk_”+ chkanswer); 返回chkanswer; } / /判断公司名称是否填写 功能chkconame(objectid) { 无功chkconame = false; 无功objectalert = ObjectId +“_alert”; 无功coname =文件。getElementById(objectid值); 如果(ChkLength(ObjectId,4)) { innerHTML(objectalert,“公司名称不小于4位字符”); } 其他的 { 如果(~ChkChar(coname,”,,,“)) { innerHTML(objectalert,“<字体颜色=绿色>正确< /字体>”); chkconame =真; } 其他的 { innerHTML(objectalert, "Cannot contain special characters" / "/ /" / ", /" &/ "/" * "); } } ChangeClass (objectAlert, chk_, +chkConame); Return chkConame; } To determine whether the air / contacts Function ChkColxr (objectId) { Var chkColxr = false; Var objectAlert = objectId+ "_alert""; Var colxr = document.getElementById (objectId).Value; If (ChkLength (objectId, 2)) { InnerHtml (objectAlert, contact no less than 2 bit characters); } Else { If ("ChkChar" (colxr, "," - & & *)) { InnerHtml (objectAlert, "correct"); ChkColxr = true; } Else { InnerHtml (objectAlert, "cannot contain special characters" / "/ /" / ", /" &/ "/" * "); } } ChangeClass (objectAlert, chk_, +chkColxr); Return chkColxr; } To determine whether the air / / / /. Function ChkCoaddress (objectId) { Var chkCoaddress = false; Var objectAlert = objectId+ "_alert""; Var coaddress = document.getElementById (objectId).Value; If (ChkLength (objectId, 4)) { InnerHtml (objectAlert, address no less than 4 bit characters); } Else { If ("ChkChar" (coaddress, "," - & & *)) { InnerHtml (objectAlert, "correct"); ChkCoaddress = true; } Else { InnerHtml (objectAlert, "cannot contain special characters" / "/ /" / ", /" &/ "/" * "); } } ChangeClass (objectAlert, chk_, +chkCoaddress); Return chkCoaddress; } To determine whether the air / / / / telephone Function ChkCotel (objectId) { ChkCotel = true; Cotel = document.getElementById (objectId).Value; ObjectAlert=objectId+ "_alert""; Var reg = /^[0-9]+$/; If (... Reg.test (Cotel)) { InnerHtml (objectAlert, "the phone is incorrectly filled"); ChangeClass (objectAlert, chk_false) ChkCotel = false; } Else { InnerHtml (objectAlert, "the phone is filled correctly"); } ChangeClass (objectAlert, chk_, +chkCotel); Return chkCotel; } Detection of telephone area code / / / / Function ChkCotelq (objectId) { ChkCotelq = true; Cotelq = document.getElementById (objectId).Value; ObjectAlert=objectId+ "_alert""; Var reg = /^[0-9]+$/; If (... Reg.test (cotelq)) { InnerHtml (objectAlert, the area code is only numeric); ChangeClass(objectalert,“chk_false”) chkcotelq = false; } 其他的 { innerHTML(objectalert,“区号填写正确”); } ChangeClass(objectalert,“chk_”+ chkcotelq); 返回chkcotelq; } 注册用户数据检测开始/ / / / 功能chkform() { chkform =真; 如果(~Chkuser(“用户”)){ 返回chkform = false; 其他{ } 如果(文件。getElementById(“user_chk”)。值= =“假”){ innerHTML(“user_alert”、“用户名已经存在”); ChangeClass(“user_alert”、“chk_false”); 其他{ } innerHTML(“user_alert”、“用户名可以正常使用”); ChangeClass(“user_alert”、“chk_true”); } } 如果(~ChkPassword(“通行证”,6)){ 返回chkform = false; } 如果(~PasswordFlag(“通行证”,“及格”)){ 返回chkform = false; } 如果(~ChkAnswer(“答案”)){ 返回chkform = false; } 如果(~ChkConame(“coname”)){ 返回chkform = false; } 如果(~ChkColxr(“colxr”)){ 返回chkform = false; } 如果(~ChkCotelq(“cotelq”)){ 返回chkform = false; } 如果(~chkcotel(“科讯”)){ 返回chkform = false; } / /邮件验证 如果(~isemail(“邮件”)){ 返回chkform = false; } 如果(~chkcoaddress(“coaddress”)){ 返回chkform = false; } / /验证码验开始 如果(~ChkImg(“IMG”)){ 返回chkform = false; 其他{ } 如果(文件。getElementById(“img_chk”)。值= =“假”){ innerHTML(“img_alert”、“验证码不正确”); ChangeClass(“img_alert”、“chk_false”); 返回chkform = false; 其他{ } innerHTML(“img_alert”、“验证码正确~”); ChangeClass(“img_alert”、“chk_true”); } } 返回chkform; }
/
本文档为【js验证信息(JS authentication information)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索