var names = $("names");
var pwds = $("pwds");
var ts1 =
$("ts1");
var ts2 = $("ts2");
var ts3 = $("ts3");
function
subtton(){
if(names.value
==null||names.value.length==0){
ts1.innerHTML ="请输入账号";
names.focus;
return
false;
}else if(pwds.value== null||pwds.value.length==
0){
ts2.innerHTML
="请输入密码";
pwds.focus;
return
false;
}else{
var r =
chekYZ();
return
r;
}
}
var xmlHttp;
function chekYZ(){
function
getXmlHttp(){
if(window.ActiveXObject){
xmlHttp = new
ActiveXObject("MICROSOFT.XMLHTTP");
}else
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
var f = false;
xmlHttp.open("GET","denglu.php?names="+names.value+"&pwds="+pwds.value,false);
xmlHttp.onreadystatechange =
function(){
if(xmlHttp.readyState
== 4){
if(xmlHttp.status ==
200){
var txt =
xmlHttp.responseText;
if(txt ==
"1"){
window.location.href="../zhuce/zhuce.php";
f =
true;
}else{
ts3.innerHTML
="账户或者密码错误!";
window.location.href="#";
f =
false;
}
}
}
}
xmlHttp.send(null);
return f;
}
function $(id){
return
document.getElementById(id)
}
原文:http://www.cnblogs.com/ZH1132672711/p/3744091.html