formValidator之校验

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page
	import="org.springside.modules.security.springsecurity.SpringSecurityUtils"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/common/js-date.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>配置信息 </title>
		<%@ include file="/common/meta.jsp"%>
		<link rel="stylesheet" type="text/css" href="${ctx}/css/member.css" />
		<script src="${ctx}/js/jquery.js" type="text/javascript"></script>
		<script src="${ctx}/js/table.js" type="text/javascript"></script>
		<script src="${ctx}/js/jquery-1.4.4.min.js" type="text/javascript"></script>
		<link type="text/css" rel="stylesheet" href="${ctx}/css/validator.css"></link>
		<script src="${ctx}/js/formValidator-4.0.1.js" type="text/javascript" charset="UTF-8"></script>
		<script src="${ctx}/js/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>

            <script type="text/javascript">
		$(document).ready(function() {
			$("#i_leasecompany_id").focus();
			$.formValidator.initConfig( {
				formID : "inputForm",
				onError : function() {
				}
			});
			$("#i_leasecompany_id").formValidator( {
				onShow : "请选择租赁公司",
				onFocus : "请选择租赁公司",
				onCorrect : "租赁公司选择正确"
			}).inputValidator( {
				min : 1,
				onError : "必须选择租赁公司"
			}).functionValidator({
				fun: check1
			});
			$("#s_table_name").formValidator( {
				onShow : "请输入同步表名,格式为:Schema.表名",
				onFocus : "请输入同步表名,格式为:Schema.表名",
				onCorrect : "同步表名输入正确"
			}).regexValidator( {
				regExp : "notempty",
				dataType : "enum",
				onError : "同步表名不能为空"
			}).regexValidator({
				regExp: "^[a-zA-Z]+\\.[a-zA-Z\\u4E00-\\u9FA5\\uF900-\\uFA2D]+$",
				dataType: "string",
				onError: "输入的同步表名不正确,格式为:Schema.表名"
			}).functionValidator({
				fun: check1
			});
			$("#s_mysql_table_name").formValidator( {
				onShow : "请输入对应的MySql表名",
				onFocus : "请输入对应的Mysql表名",
				onCorrect : "Mysql数据库表名输入正确"
			}).regexValidator( {
				regExp : "notempty",
				dataType: "enum",
				onError : "对应的Mysql表名不能为空"
			}).regexValidator({
				regExp: "^[a-zA-Z_]{3,}$",
				dataType: "string",
				onError: "输入Mysql表名格式不对"
			}).functionValidator({
				fun: check
			});
			$("#s_sync_config").formValidator( {
				onShow : "请输入同步配置内容,格式为:同步字段名,类型名,Mysql对应名/",
				onFocus : "请输入同步配置内容,格式为:同步字段名,类型名,Mysql对应名/",
				onCorrect : "同步配置内容输入正确"
			}).regexValidator( {
				regExp : "notempty",
				dataType:"enum",
				onError : "同步配置内容不能为空,格式为:同步字段名,类型名,Mysql对应名/"
			}).regexValidator({
				regExp: "^([0-9a-zA-Z\\u4E00-\\u9FA5\\uF900-\\uFA2D]{2,}\,[a-zA-Z]{3,}\,[a-zA-Z_]{5,}\/)+$",
				dataType:"string",
				onError:"同步配置内容格式不对,格式为:同步字段名,类型名,Mysql对应名/"
			});
			
			function check1(){
				var $mysqltable = $.trim($("#s_mysql_table_name").val());
				if($mysqltable !=null && $mysqltable!=""){
					$("#s_mysql_table_name").focus();
					$("#s_mysql_table_name").blur();
				}
			}
			
			function check(){
				var msg = $.ajax({
					type: "post",
					url:"syncconfig!check.action?v="
						+$("#i_leasecompany_id").val()
						+"&v1="+encodeURI($("#s_table_name").val())
						+"&v2="+encodeURI($("#s_mysql_table_name").val())
						+"&v3="+$("#id").val()
						+"&p="+new Date(),
					async: false
				}).responseText;
				if(msg.toString() == "true"){
					return "该配置已经存在";
				}else{
					return true;
				}
			}
			
		});

	</script>
</head>
	<body>
			<div class="crumbs" style="height: auto;">
				您现在的位置:
				<a href="${ctx}/main/main.jsp">云租车后台 > 租赁公司同步配置管理</a> >
				<span class="curr">添加租赁公司同步配置信息</span>
			</div>
			<div class="greybox" style="height: 320px;">
				<div class="greytit">
					<h2>
						<s:if test="id == null">添加</s:if>
						<s:else>修改</s:else>
						租赁公司同步配置信息
					</h2>

				</div>
				<form id="inputForm" action="syncconfig!save.action" method="post">
					<input type="hidden" name="id"  id="id" value="${id}" />
					<input type="hidden" name="username" id="username"
						value="<%=SpringSecurityUtils.getCurrentUserName()%>" />

					<div style="height: auto;">
						<div class="width100" style="height: 10px;"></div>
						<div class="width100" style="height: 30px;">
							<div align="right" class="text-left">
								公司名称:
							</div>
							<div class="text-right1">
								<select name="i_leasecompany_id" id="i_leasecompany_id" style="width: 180px;"
									onchange="">
									<option value="">
										--请选择--
									</option>
									<c:forEach items="${leasecompanylist}" var="company"
										varStatus="index">
										<c:if test="${company.i_record_status !=1}">
										 <c:if test="${company.i_record_status !=2}">
											<option value="${company.id}"
												<c:if test="${i_leasecompany_id == company.id}">selected="selected"</c:if>>
												${company.s_keypost_desc}
											</option>
											</c:if>
										</c:if>
									</c:forEach>
								</select>
							</div>
							<div class="red" id="i_leasecompany_idTip"
								style="width: 200px; float: left;">
								*
							</div>
						</div>

						<div class="width100" style="height: 30px;">
							<div align="right" class="text-left">
								同步表名:
							</div>
							<div class="text-right1">
								<input name="s_table_name" id="s_table_name"
									type="text" value="${s_table_name}" class="text-input" maxlength="100" style="width: 180px"/>
							</div>
							<div class="red" id="s_table_nameTip"
								style="width: 250px; float: left;">
								*
							</div>
						</div>
						
						<div class="width100" style="height: 30px;">
							<div align="right" class="text-left">
								MySql表名:
							</div>
							<div class="text-right1">
								<input name="s_mysql_table_name" id="s_mysql_table_name"
									type="text" value="${s_mysql_table_name}" class="text-input"  maxlength="100" style="width: 180px"/>
							</div>
							<div class="red" id="s_mysql_table_nameTip"
								style="width: 200px; float: left;">
								*
							</div>
						</div>
						
						<div class="width100" style="height: 100px;width: 100%">
							<div align="right" class="text-left">
								同步配置内容:
							</div>
							<div class="text-right1" style="height: 60px;">
								<textarea rows="5" cols="100" name="s_sync_config" id="s_sync_config">${s_sync_config}</textarea>
							</div>
							<div class="red" id="s_sync_configTip" 
								style="width: 200px; float:left; width: 400px">
								*
							</div>
						</div>

						<div align="right"
							style="padding-right: 5px; padding-bottom: 5px;">
							<div class="width100" style="height: 30px;">
								<div align="right" class="text-left"></div>
								<div class="text-right1">
									<img src="${ctx }/images/tij_but.gif" border="0"
										onclick="submit_form()" />
								</div>
								<div class="text-right1">
									<img src="${ctx }/images/guanb_but.gif"
										onclick="history.back()" border="0" />
								</div>
							</div>

						</div>
					</div>
				</form>
			   </div>
			   
	  <script>
		function submit_form() {
			$("#inputForm").submit();
		}
	</script>
	</body>

</html>

实现以下功能

formValidator之校验_第1张图片

你可能感兴趣的:(formValidator之校验)