电脑安全

您当前的位置:主页 > 电脑安全 >

ajax验证用户名二-网络编程

来源:[db:来源]标题:   密码    编辑:电脑技术全能网 时间:2019-09-18 18:01

原标题:ajax验证用户名二-网络编程
   当初咱们把check.js文件代码来看看吧.function c(){var uid=document.getElementById('uid').value;var pwd=document.getElementById('password').value;var pwd2=document.getElementById('password2').value;var mo=document.getElementById('mo').value;var name=document.getElementById('name').value;if( uid=='' || uid.length>12 || uid.length<3 ){document.getElementById('u_info').innerHTML='<div id=error>昵称长度为3-12字符!</div>';return false;}else{document.getElementById('u_info').innerHTML='<div class="defult">用户名长度3-12位</div>';}if(pwd =='' || pwd!=pwd2 || pwd.length<6 || pwd.length>12){document.getElementById('p_info').innerHTML='<div id=error>暗码不能为空或二次输出的暗码纷歧致!</span>';return false;}else{document.getElementById('p_info').innerHTML='<div id=success></div>';document.getElementById('p_info1').innerHTML='<div id=success></div>';}if( mo.match(/^[0-9]{3,4}-[0-9]{7,8}$/) || mo.match(/^(((d{3}))|(d{3}-))?13d{9}$/) ){document.getElementById('m_info').innerHTML='<div id=success></div>';}else{document.getElementById('m_info').innerHTML='<div id=error>手机13875888888与座机(0731-888888)</span>';return false;}if( name=='' || name.length>12 || name.length<2 ){document.getElementById('n_info').innerHTML='<div id=error>请输出你的实在姓名!</span>';return false;}else{document.getElementById('n_info').innerHTML='<div id=success></div>';}}var xmlHttp = false;function ajaxcreate(){try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e2) {xmlHttp = false;}}if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {xmlHttp = new XMLHttpRequest();}if(!xmlHttp){alert('Create Xmlhttp Fail ');return false;}}function ajax(){ajaxcreate();var xmvalue=document.getElementById("uid").value;var url="ajax_check.php?txt="+encodeURI(xmvalue);if (xmvalue== null || xmvalue.length>20 || xmvalue == "") return false;xmlHttp.open("POST",url,true);xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.send(xmvalue);xmlHttp.onreadystatechange=returnstate;}function returnstate(){if(xmlHttp.readyState != 4 ){document.getElementById("u_info").innerHTML="<div class=defult>正在考证请稍后...</div>";}if(xmlHttp.readyState == 4 ){document.getElementById("u_info").innerHTML=xmlHttp.responseText;}}

上一篇:php获取某个目录大小-网络编程

下一篇:没有了