• JavaScript表单项数据过滤代码


    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <script type="text/javascript">
    	window.onload = function(){
    		document.getElementById("admin").focus();	
    	}
    	function check_admin(admininfo){
    		if(admininfo==null || admininfo.length == 0 || !new RegExp(/^[a-zA-Z]{3,20}$/).test(admininfo)){
    			return false ;
    		}else{
    			return true ;
    		}
    	}
    	function check_pwd(pwdinfo){
    		if(pwdinfo==null || pwdinfo.length == 0 || !new RegExp(/^d{6}$/).test(pwdinfo)){
    			return false ;
    		}else{
    			return true ;
    		}
    	}
    	function check_yzm(yzminfo){
    		if(yzminfo==null || yzminfo.length == 0 || !new RegExp(/^[A-Za-z0-9]{5}$/).test(yzminfo)){
    			return false ;
    		}else{
    			return true ;
    		}
    	}
    	
    	function onblur_show_admin_success_msg(){
    		var admin = document.getElementById("admin").value ;
    		var flag = check_admin(admin);
    		if(flag){
    			document.getElementById("admin_msg").innerHTML = "<b style='color:green;'>格式正确。</b>" ;
    		}else{
    			document.getElementById("admin_msg").innerHTML = "管理员账号有误,请又一次填写!" ;
    		}
    	}
    	function onblur_show_pwd_success_msg(){
    		var pwd = document.getElementById("pwd").value ;
    		var flag = check_pwd(pwd) ;
    		if(flag){
    			document.getElementById("pwd_msg").innerHTML = "<b style='color:green;'>格式正确!

    </b>" ; }else{ document.getElementById("pwd_msg").innerHTML = "管理员password有误。请又一次填写!" ; } } function onblur_show_yzm_success_msg(){ var yzm = document.getElementById("yzm").value ; var flag = check_yzm(yzm) ; if(flag){ document.getElementById("yzm_msg").innerHTML = "<b style='color:green;'>格式正确。</b>" ; }else{ document.getElementById("yzm_msg").innerHTML = "验证码有误,请又一次填写!

    " ; } } function clear_admin_msg(){ document.getElementById("admin_msg").innerHTML = "" ; } function clear_pwd_msg(){ document.getElementById("pwd_msg").innerHTML = "" ; } function clear_yzm_msg(){ document.getElementById("yzm_msg").innerHTML = "" ; } function onsubmit_check_all_data(){ var admin = document.getElementById("admin").value ; var pwd = document.getElementById("pwd").value ; var yzm = document.getElementById("yzm").value ; if(!check_admin(admin)||!check_pwd(pwd)||!check_yzm(yzm)){ return false ; } /* var flag_admin = check_admin(admin) ; var flag_pwd = check_pwd(pwd); var flag_yzm = check_yzm(yzm); if(flag_admin&&flag_pwd&&flag_yzm){ return true ; }else{ return false ; } if(!flag_admin||!flag_pwd||!flag_yzm){ return false ; } */ } </script> <div class="body"> <div class="login"> <form action="login.action" method="post" class="loginform" onsubmit="return onsubmit_check_all_data();"> <fieldset> <legend>系统管理员登陆窗体</legend> <div class="margin_padding"></div> <p> <label for="admin">管理员账号</label><br/> <span class="margin_padding"></span> <input type="text" name="admin" id="admin" style="200px;height:25px;" onfocus="clear_admin_msg();" onblur="onblur_show_admin_success_msg();"> <span id="admin_msg" style="color: red;font-style: italic;"></span> </p> <span class="margin_padding"></span> <p> <label for="pwd">管理员password</label><br/> <span class="margin_padding"></span> <input type="password" name="pwd" id="pwd" style="200px;height:25px;" onfocus="clear_pwd_msg();" onblur="onblur_show_pwd_success_msg();"> <span id="pwd_msg" style="color: red;font-style: italic;"></span> </p> <span class="margin_padding"></span> <p> <label for="yzm">输入验证码</label><span style="color:#555;font-size:10px;">(看不清楚,请点击图片刷新!

    )</span><br> <span class="margin_padding"></span> <input type="text" name="yzm" id="yzm" style="100px;height:25px;" onfocus="clear_yzm_msg();" onblur="onblur_show_yzm_success_msg();"> <img alt="loading..." src="yzm.action" style="100px;height:25px;" id="yzmpic" onclick="refrushyzm();" onmouseover="showpointer();"> <span id="yzm_msg" style="color: red;font-style: italic;"></span> </p> <span class="margin_padding"></span> <p> <input type="submit" value="管理员登录" id="submit"> </p> <span class="margin_padding"></span> </fieldset> </form> </div> </div>


  • 相关阅读:
    flash 观察帧频率的工具 fps counter
    flash builder 找不到所需要的AdobeFlashPlayer调试器版本
    好文好文
    win7下flash builder 4.5无法设置Courier New字体
    AS3日期工具
    png图片 透明区域如何 让其不响应鼠标事件?
    Access插入数据
    异步正则
    log4net异步刷新 TextBox (试运行版)
    Python对Xpath的支持
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/6930390.html
Copyright © 2020-2023  润新知