ajax 注册验证

现在我们把check.js文件代码来看看吧.

ajax 注册验证,今天这个文章有一点怪了,就是验证url 是否能被正常访问哦,

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.length12
|| uid.length3 ){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.length6 ||
pwd.length12){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与座机/span’;return false;}if( name==” ||
name.length12 || name.length2
){document.getElementById(‘n_info’).innerHTML=’div
id=error请输入你的真实姓名!/span’;return
false;}else{document.getElementById(‘n_info’).innerHTML=’div
id=success/div’;}

tr td height=34 align=center博客地址:/td td height=25 align=centerspan
class=STYLE1*/span/td tdlabel input name=blog type=text id=blog size=47
onblur=ajax(0); / /label/td td id=u_info/td /tr

}

上面是简单的html代码程序.下面贴出php 验证代码.

var xmlHttp = false;

if( $ta==0){if(@file_get_contents($xm)){echo ‘div
id=successnbsp;nbsp;nbsp;nbsp;博客地址可以访问/div’;}else{echo ‘div
id=error对不起,你输入的博客地址不能正常访问div ‘;}}else{echo div
id=’error’对不起,无效的操作!/div;}

function ajaxcreate(){

好了我还是反ajax 代码也写出来吧,

try {xmlHttp = new ActiveXObject(Msxml2.XMLHTTP);} catch (e) {try
{xmlHttp = new ActiveXObject(Microsoft.XMLHTTP);} catch (e2) {xmlHttp =
false;}}

var xmlHttp = false;

if (!xmlHttp typeof XMLHttpRequest != ‘undefined’) {xmlHttp = new
XMLHttpRequest();}if(!xmlHttp){alert(‘Create Xmlhttp Fail ‘);return
false;}}

function ajaxcreate(){

function ajax(){ajaxcreate();var
xmvalue=document.getElementById(uid).value;var
url=ajax_check.php?txt=+encodeURI(xmvalue);if (xmvalue== null ||
xmvalue.length20 || xmvalue == ) return
false;xmlHttp.open(POST,url,true);xmlHttp.setRequestHeader(Content-Type,application/x-);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;}}

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;}}

ajaxcreate();xmvalue=document.getElementById(blog).value;var
url=ajax_check.php?txt=+encodeURI(xmvalue)+tag=+encodeURI(str)+rd=+Math.random();if
(xmvalue== null || xmvalue.length200 || xmvalue == ) return
false;xmlHttp.open(POST,url,true);xmlHttp.setRequestHeader(Content-Type,application/x-);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;}}

OK下面这段我以前写过了,不过为了方便还是也写出来了,最后申明一下:本站原创文章转载请注明来:

发表评论

电子邮件地址不会被公开。 必填项已用*标注