Ajax 密码验证

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

上一篇:Effective C++ -----条款24:若所有参数皆需类型转换,请为此采用non-member函数


下一篇:JavaScript 概览 更新时间2014-0414-0837