Ajax Registration Validation

Source: Internet
Author: User

Ajax registration Verification, today this article is a bit strange, is to verify that the URL can be normal access Oh,

<tr>
<TD height= "align=" "Center" > Blog Address:</td>
<TD height= "align=" "Center" ><span class= "STYLE1" >*</span></td>
<td><label>
<input name= "blog" type= "text" id= "blog" size= "" onblur= "Ajax (0);" />
</label></td>
<TD id= "U_info" ></td>
</tr>

The above is a simple HTML code program. The following is a PHP validation code.

if ($ta ==0) {
if (@file_get_contents ($XM)) {
Echo ' <div id= "success" >&nbsp;&nbsp;&nbsp;&nbsp; blog address can access </div> ';
}else{
Echo ' <div id= "error" > Sorry, the blog address you entered cannot be accessed normally <div > ';
}
}else{
echo "<div id= ' error ' > Sorry, invalid operation!</div>";
}

Okay, I'll just write back the anti-Ajax code,

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

Ajaxcreate ();
Xmvalue=document.getelementbyid ("blog"). Value;
var url= "ajax_check.php?txt=" +encodeuri (xmvalue) + "&tag=" +encodeuri (str) + "&rd=" +math.random ();
if (xmvalue== null | | xmvalue.length>200 | | | 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> is verifying please ...</div> later";
}
if (xmlhttp.readystate = = 4) {
document.getElementById ("U_info"). Innerhtml=xmlhttp.responsetext;

}
}

OK below this paragraph I have written before, but in order to facilitate or also write out, the final statement: This site original article reproduced please specify: www.111cn.net/phper/php.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.