zoukankan      html  css  js  c++  java
  • Ajax方式实现注册验证代码

    经常用到的经典Ajax代码,记录备用:

     function CreateAjax()
     {
        var XMLHttp;
        try
        {
            XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");   //IE的创建方式
        }
        catch(e)
        {
            try
            {
                XMLHttp = new XMLHttpRequest();     //FF等浏览器的创建方式
            }
            catch(e)
            {
                XMLHttp = false;        //创建失败,返回false
            }
        }
        return XMLHttp;     //返回XMLHttp实例
     }
    
    //验证用户名是否为空
    function GetAdminID(){
    	var AdminID = document.getElementById('AdminID').value;
    	if (AdminID==""){
    		document.getElementById('dl_AdminID').innerHTML='<img src="images/icon_cross_sml.gif" width="16" height="16"> 请输入用户名!';
    		return false;
    	}else{
    		document.getElementById('dl_AdminID').innerHTML='';
    		return true;
    	}
    }
    
    //验证密码是否为空
    function GetPassWord(){
    	var PassWord = document.getElementById('PassWord').value;
    	if (PassWord==""){
    		document.getElementById('dl_PassWord').innerHTML='<img src="images/icon_cross_sml.gif" width="16" height="16"> 请输入密码!';
    		return false;
    	}else{
    		document.getElementById('dl_PassWord').innerHTML='';
    		return true;
    	}
    }
    
    //验证码是否为空
    function GetRand(){
    	var Rand = document.getElementById('Rand').value;
    	if (Rand==""){
    		document.getElementById('dl_Rand').innerHTML='<img src="images/icon_cross_sml.gif" width="16" height="16"> 请输入验证码!';
    		return false;
    	}else{
    		document.getElementById('dl_Rand').innerHTML='';
    		return true;
    	}
    }
    
    function chklogin(){
    if (GetAdminID()==false){
        return false;
    }
    if (GetPassWord()==false){
    	return false;
    }
    if (GetRand()==false){
    	return false;
    }
    return true;
    }
    

      

  • 相关阅读:
    mac pro发热发热发热
    从零开始搭建Vue组件库
    Charles模拟弱网测试
    webpack
    异步加载脚本
    Angular
    JavaScript模板语言
    Node.js
    gulp
    jsonp原理
  • 原文地址:https://www.cnblogs.com/shanmao/p/3467386.html
Copyright © 2011-2022 走看看