zoukankan      html  css  js  c++  java
  • 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>


  • 相关阅读:
    androidstudio gradle下载速度慢
    paddlex 使用-11 实例图像分割
    paddlex 使用-10 语义图像分割
    redis C# Windows下测试环境
    CSS Flex弹性布局(多个div自动换行)
    扩展排序后重新编号
    纯css制作的打勾(√)小图标
    layui表格-template模板的三种用法
    VB中各种数据类型转换函数
    将ACCESS 的数据库中的表的文件 导出了EXCEL格式
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/6930390.html
Copyright © 2011-2022 走看看