ajaxLogin(){
    var WebsUrl = 'http://s:81/userapp/login.asmx/Login?';
    
if(!CheckLoadfocus(document.all.MyUserName)  )    {    
        alert(
'用户名不合法,请返回');
        
return false;
    }
else if (!CheckLoadfocus(document.all.MyUserName)  )    {    
        alert(
'密码不合法,请返回');
        
return false;
    }
    
var UrlStr = WebsUrl +'UserName='+document.all.MyUserName.value+'&UserPassword=
'+document.all.MyPassword.value;
    AjaxLogin(UrlStr);
    
return false;
}
function CheckLoadfocus(thise){
    
var sReg='([a-zA-Z0-9]+){3,}$';
    
var reg = new RegExp(sReg,"i");
    
try{
        
if(!reg.test(thise.value)){
            thise.value 
='admin';
            thise.style.background
='#FFFFBF';
            thise.focus();
            thise.select();
            alert(
'提交不合法,请返回');
            
return false;
        }
    thise.select();
    thise.style.background
='#FFF';

    }
catch(e){}
    
return true;
}

function AjaxLogin(file){
  
var xmlObj = null;
  
if(window.XMLHttpRequest){
      xmlObj 
= new XMLHttpRequest();
  } 
else if(window.ActiveXObject){
      xmlObj 
= new ActiveXObject("Microsoft.XMLHTTP");
  } 
else {
      
return;
  }

  xmlObj.onreadystatechange 
= function(){
    
if(xmlObj.readyState == 4){
        
var rstr;
        
var mylevl = parseInt(xmlObj.responseXML.getElementsByTagName('int')[0].firstChild.data);
        
if(mylevl>0){
            rstr
=('登陆成功,权限是'+mylevl);
        }
else{
            rstr
=('登陆失败');
        }
        alert(rstr);
     }
    }
    xmlObj.open (
'GET', file, true);
    xmlObj.send (
'');
  }

相关文章:

  • 2021-12-25
  • 2021-08-21
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-09-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-11-25
  • 2021-04-23
相关资源
相似解决方案