`
这些年
  • 浏览: 389093 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

集成前台验证框架

    博客分类:
  • js
 
阅读更多

1:下载地址

         http://www.17sucai.com/pins/312.html

2:加入到项目

        须要把Validform.js和图片加到项目的目录中

3:加入jsp页面

     导入的包:(在提交时会验证所有表单,如果没有submit,使用btnSubmit)

<script type="text/javascript" 
src="resources/tableValidation/tableValid.js"></script>    //导入验证js
<script type="text/javascript"> 
$(function() { 
$(".aa:last").Validform({        //给表单“aa”加上验证,aa必须是from表单,否则会报找不到action
tiptype : 2,                     //表单验证失败的提示方式
btnSubmit:"#btn_sub",            //如果表单中没有from,而是button,这是提交按钮的id   
callback : function(data) { 
if (data.status == "y") { 
setTimeout(function() { 
$.Hidemsg(); 
}, 2000); 
} 
} 
}); 
}) 
</script> 
<style type="text/css"> 
@import "${projectPath}/resources/tableValidation/valid.css";      //加入css
</style>

 

    表单项须要加上控件(ignore="ignore" 空值证验会失效)

<tr>
	<td>频道名称:</td>
	<td><s:input path="channelname" class="form-control"
			placeholder="频道请从rcms中复制"
                       datatype="channelname"                 //证验的类型,包含自带的空值证验,与nullmsg一起用
			nullmsg="请输入频道名称"                 //空值的提示信息
                       errormsg="请在rcms中复制" />                //证验错误信息
        <c:out  value="${channelnameerror}"></c:out>
	</td>
	<td><div class="Validform_checktip">请输入频道名称</div>    //错误信息显示位置
	</td>
</tr>

  4:因为插件不满足需求,须要自己加上datatype为"channelname"的验证 (部分)

$.fn.Validform.sn={
		defaults:{
			tiptype:1,
            ajaxPost:false
		},
		
		regcheck:function(type,gets){
            var reg;
			switch(type){
			    case "*":
				    return true;
				case "positiveinteger": /* 正整数 */
					reg= /^[0-9]*[1-9][0-9]*$/;
					return reg.test(gets);
				case "channelname": /* 频道名称 */
					reg1= /^[a-z0-9][a-z0-9]*:\/\/[a-z0-9][-a-z0-9_]*(\.[a-z0-9][-_a-z0-9]*){1,}$/;
					reg2= /^[a-z0-9][a-z0-9]*:\/\/[*]\.[a-z0-9][-a-z0-9]*(\.[a-z0-9][-a-z0-9]*){1,}$/;
					return reg1.test(gets)||reg2.test(gets);
				default:
					return false;
			}
		},

 5:如果须要特殊须求须要重写checkform:function(obj,parentobj,tiptype,show)(比如我须要判断第一个文本框值比第二个大)

     jsp中的内容

<tr>
	<td>告警上限:</td>
	<td><s:input path="uplimit" class="form-control"
			placeholder="单位(MB)" datatype="positiveinteger" nullmsg="请输入告警上限"
			errormsg="请输入正整数" /></td>
	<td><div class="Validform_checktip">请输入正整数</div>
	</td>
</tr>
<tr>
	<td>告警下限:</td>
	<td><s:input path="downlimit" class="form-control"
			placeholder="单位(MB)" 
                       datatype="*"                   //验证类型为*,js中直接返回true
                       greaterthan="uplimit"          //greaterthan为自己新建的标签,它传上要比较的文本框id
		        nullmsg="请输入告警下限"
                       errormsg="请输入正整数,并小于上限" />
	</td>
	<td><div class="Validform_checktip">请输入正整数</div>
	</td>
</tr>

   Validform.js的checkform:function里加入

 

if(obj.attr("greaterthan")){
				var theother=parentobj.find("input[name="+obj.attr("greaterthan")+"]:first");
				var reg= /^[0-9]*[1-9][0-9]*$/;
				if(obj.val()>=theother.val()||!reg.test(obj.val())){
					errorobj=obj;
					this.showmsg(errormsg,tiptype,{obj:obj},show);
					return false;
				}
			}

 

补充:完整代码

   tableValid.js

/*
	通用表单验证方法
	Validform version 2.0
	For more information, you can visit http://www.rjboy.cn
	By sean at April 7, 2010 - April 22, 2011
	
	Demo:
	$(".demoform").Validform({//$(".demoform")指明是哪一表单需要验证,名称需加在from表单上;
		btnSubmit:"#btn_sub", //#btn_sub是该表单下要绑定点击提交表单事件的按钮;如果form内含有submit按钮该参数可省略;
		tiptype:1, //可选项 1=>pop box,2=>side tip,默认为1;
		postonce:true, //可选项 是否开启网速慢时的二次提交防御,true开启,不填则默认关闭;
		ajaxPost:true, //使用ajax方式提交表单数据,默认false,提交地址就是action指定地址;
		callback:function(data){
			//返回数据data是json格式,{"info":"demo info","status":"y"}
			//info: 输出提示信息;
			//status: 返回提交数据的状态,是否提交成功。如可以用"y"表示提交成功,"n"表示提交失败,在ajax_post.php文件返回数据里自定字符,主要用在callback函数里根据该值执行相应的回调操作;
			//你也可以在ajax_post.php文件返回更多信息在这里获取,进行相应操作;
			
			//这里执行回调操作;
		}
	});
*/

(function($){
	var errorobj=null,// 指示当前验证失败的表单元素;
		msgobj,// pop box object
		msghidden=true, // msgbox hidden?
		tipmsg={// 默认提示文字;
			w:"请输入正确信息!",
			r:"通过信息验证!",
			c:"正在检测信息…",
			s:"请填入信息!",
			v:"所填信息没有经过验证,请稍后…",
			p:"正在提交数据…"
		},
		creatMsgbox=function(){
			if($("#Validform_msg").length!==0){return false;}
			msgobj=$('<div id="Validform_msg"><div class="Validform_title">提示信息<a class="Validform_close" href="javascript:void(0);">&chi;</a></div><div class="Validform_info"></div><div class="iframe"><iframe frameborder="0" scrolling="no" height="100%" width="100%"></iframe></div></div>').appendTo("body");// 提示信息框;
			msgobj.find("a.Validform_close").click(function(){
				msgobj.hide();
				msghidden=true;
				if(errorobj){
					errorobj.focus().addClass("Validform_error");
				}
				return false;
			}).focus(function(){this.blur();});

			$(window).bind("scroll resize",function(){
				if(!msghidden){				  
					var left=($(window).width()-msgobj.width())/2;
					var top=($(window).height()-msgobj.height())/2;
					var topTo=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)+(top>0?top:0);
					msgobj.animate({
						left : left,
						top : topTo
					},{ duration:400 , queue:false });
				}
			});
		};
	
	$.fn.Validform=function(settings){
		var defaults={};
		settings=$.extend({},$.fn.Validform.sn.defaults,settings);
		
		this.each(function(){
			var $this=$(this);
			var posting=false; // 防止表单按钮双击提交两次;
			$this.find("[tip]").each(function(){// tip是表单元素的默认提示信息,这是点击清空效果;
				var defaultvalue=$(this).attr("tip");
				var altercss=$(this).attr("altercss");
				$(this).focus(function(){
					if($(this).val()==defaultvalue){
						$(this).val('');
						if(altercss){$(this).removeClass(altercss);}
					}
				}).blur(function(){
					if($.trim($(this).val())===''){
						$(this).val(defaultvalue);
						if(altercss){$(this).addClass(altercss);}
					}
				});
			});
			
			// 绑定blur事件;
			$this.find("[datatype]").blur(function(){
				var flag=true;
				flag=$.fn.Validform.sn.checkform($(this),$this,settings.tiptype,"hide");

				if(!flag){return false;}
				if(typeof(flag)!="boolean"){// 如果是radio, checkbox,
											// select则不需再执行下面的代码;
					$(this).removeClass("Validform_error");
					return false;
				}
										
				flag=$.fn.Validform.sn.regcheck($(this).attr("datatype"),$(this).val());
				if(!flag){
					if($(this).attr("ignore")==="ignore" && ( $(this).val()==="" || $(this).val()===$(this).attr("tip") )){
						if(settings.tiptype==2){
							$(this).parent().next().find(".Validform_checktip").removeClass().addClass("Validform_checktip").text($(this).attr("tip"));
						}
						flag=true;
						return true;
					}
					errorobj=$(this);
					$.fn.Validform.sn.showmsg($(this).attr("errormsg")||tipmsg.w,settings.tiptype,{obj:$(this)},"hide"); // 当tiptype=1的情况下,传入"hide"则让提示框不弹出,tiptype=2的情况下附加参数“hide”不起作用;
				}else{
					if($(this).attr("ajaxurl")){
						var inputobj=$(this);
						inputobj.attr("valid",tipmsg.c);
						$.fn.Validform.sn.showmsg(tipmsg.c,settings.tiptype,{obj:inputobj,type:1},"hide");
						$.ajax({
							type: "POST",
							url: inputobj.attr("ajaxurl"),
							data: "param="+$(this).val(),
							dataType: "Json",
							success: function(data){
								if(data.Data=="success"){
									inputobj.attr("valid","true");
									$.fn.Validform.sn.showmsg(tipmsg.r,settings.tiptype,{obj:inputobj,type:2},"hide");
								}else{
									inputobj.attr("valid",data.Message);
									errorobj=inputobj;
									$.fn.Validform.sn.showmsg(data.Message,settings.tiptype,{obj:inputobj});
								}
							}
						});
					}else{
						errorobj=null;
						$.fn.Validform.sn.showmsg(tipmsg.r,settings.tiptype,{obj:$(this),type:2},"hide");
					}
				}
				
			});
			
			// subform
			var subform=function(){
				var flag=true;
				if(posting){return false;}
				
				$this.find("[datatype]").each(function(){
					flag=$.fn.Validform.sn.checkform($(this),$this,settings.tiptype);

					if(!flag){
						errorobj.focus();
						return false;
					}
					
					if(typeof(flag)!="boolean"){
						flag=true;
						return true;
					}
					
					flag=$.fn.Validform.sn.regcheck($(this).attr("datatype"),$(this).val());
					
					if(!flag){
						if($(this).attr("ignore")==="ignore" && ( $(this).val()==="" || $(this).val()===$(this).attr("tip") )){
							flag=true;
							return true;
						}
						errorobj=$(this);
						errorobj.focus();
						$.fn.Validform.sn.showmsg($(this).attr("errormsg")||tipmsg.w,settings.tiptype,{obj:$(this)});
						return false;
					}
					
					if($(this).attr("ajaxurl")){
						if($(this).attr("valid")!="true"){
							flag=false;
							var thisobj=$(this);
							errorobj=thisobj;
							errorobj.focus();
							$.fn.Validform.sn.showmsg(thisobj.attr("valid") || tipmsg.v,settings.tiptype,{obj:thisobj});
							if(!msghidden || settings.tiptype==2){
								setTimeout(function(){
									thisobj.trigger("blur");
								},2000);
							}
							return false;
						}else{
							$.fn.Validform.sn.showmsg(tipmsg.r,settings.tiptype,{obj:$(this),type:2},"hide");
							flag=true;
						}
					}
				});
				
				if(flag && !posting){
					errorobj=null;
					if(settings.postonce){posting=true;}
					if(settings.ajaxPost){
						$.fn.Validform.sn.showmsg(tipmsg.p,settings.tiptype,{obj:$(this)},"alwaysshow");// 传入“alwaysshow”则让提示框不管当前tiptye为1还是2都弹出;
						$.ajax({
							type: "POST",
							dataType:"json",
							url: $this.attr("action"),
							data: $this.serialize(),
							success: function(data){
								$.fn.Validform.sn.showmsg(data.info,settings.tiptype,{obj:$(this)},"alwaysshow");
								(settings.callback)(data);
							}
						});
						return false;
					}else{
						if(settings.is_submit){
						$this.get(0).submit();
						}
					}
				}
				
			};
			
			settings.btnSubmit && $this.find(settings.btnSubmit).bind("click",subform);
			$this.submit(function(){
				subform();
				return false;
			});
		});
		
		// 预创建pop box;
		if(settings.tiptype!=2 || settings.ajaxurl){		
			creatMsgbox();
		}
		
	};
	
	$.fn.Validform.sn={
		defaults:{
			tiptype:1,
            ajaxPost:false,
            is_submit:true
            
		},
		
		regcheck:function(type,gets){
			if(type.indexOf(' ')!=-1){// 多类型验证
				var types = type.split(' ');
				for (var t in types){
					if(arguments.callee.call(this,types[t],gets)){
						continue;
					}else{
						return false;
					}
				}
				return true;
			}else{
				var reg;
				switch(type){
				case "*":
					return true;
				case "k":
					reg= /^[0-9]{1}(\.[0-9]{1,2}){0,1}$/;
					return reg.test(gets);
				case "personname":
					var reg=/^[a-zA-Z0-9\x00-\xff]+/g;
					return reg.test(gets);
				case "chinese":
					var reg=/[^\x00-\xff]/g;
					return reg.test(gets);
				case "notnull":
					reg= /(^\s*)|(\s*$)/g;
					if(!gets)
						return false;
					gets = gets.replace(reg,'');
					return gets.length? true : false ;
				case "positiveinteger": /* 0和正整数 */
					reg= /^[0-9]{1,11}$/;
					return reg.test(gets);
				case "positivenumber":/* 正数 */
					reg=/^[1-9]{0,1}[0-9](\.[0-9]{1,2}){0,1}$/;
					return reg.test(gets);
				case "channelname": /* 频道名称 */
					reg1= /^[a-z0-9][a-z0-9]*:\/\/[a-z0-9][-a-z0-9_]*(\.[a-z0-9][-_a-z0-9]*){1,}$/;
					reg2= /^[a-z0-9][a-z0-9]*:\/\/[*]\.[a-z0-9][-a-z0-9]*(\.[a-z0-9][-a-z0-9]*){1,}$/;
					return reg1.test(gets)||reg2.test(gets);
				case "email": /* 邮箱 */
					var emails=gets.split(",");
					reg = /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$/;
					for(var key in emails){
						if(!reg.test(emails[key])){
							return false;
						}
					}
					return true;
				case "sms": /* 手机验证 */
					var sms=gets.split(",");
					reg= /^[0-9]{11}$/;
					for(var key in sms){
						if(!reg.test(sms[key])){
							return false;
						}
					}
					return true;
				case "isp_hold": /* isp分配比例 */
					var isp=gets.split(":");
					var isps = 0.0;
					reg = /^((\d+)(?:\.\d+)?:){4,4}((\d+)(?:\.\d+)?)$/;
					if(!reg.test(gets)) {
						return false;
					}
					for(var key in isp){
						isps= isps+parseFloat(isp[key]);
					}
					if(isps<=0) {
						return false;
					}
					return true;
				default:
					return false;
				}
			}
		},
		
		showmsg:function(msg,type,o,show){// o:{obj:当前对象, type:1=>正在检测 |
											// 2=>通过},
											// show用来判断tiptype=1的情况下是否弹出信息框;
			if(errorobj){errorobj.addClass("Validform_error");}
			
			if(type==1 || show=="alwaysshow"){
				msgobj.find(".Validform_info").text(msg);
			}

			if(type==1 && show!="hide" || show=="alwaysshow"){
				msghidden=false;
				msgobj.find(".iframe").css("height",msgobj.height());
				var left=($(window).width()-msgobj.width())/2;
				var top=($(window).height()-msgobj.height())/2;
				top=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)+(top>0?top:0);
				msgobj.css({
					"left":left
				}).show().animate({
					top:top
				},100);
			}
			
			if(type==2){
				if(o.type){
					switch(o.type){
						case 1:// 正在检测;
							o.obj.parent().next().find(".Validform_checktip").removeClass().addClass("Validform_checktip Validform_loading").text(msg);
							break;
						case 2:// 检测通过;
							o.obj.parent().next().find(".Validform_checktip").removeClass().addClass("Validform_checktip Validform_right").text(msg);	
					}
				}else{
					o.obj.parent().next().find(".Validform_checktip").removeClass().addClass("Validform_wrong Validform_checktip").text(msg);
				}
			}
			
		},
		
		checkform:function(obj,parentobj,tiptype,show){// show用来判断是表达提交还是blur事件引发的检测;
			var errormsg=obj.attr("errormsg") || tipmsg.w;
			
			if(obj.is("[datatype='radio']")){  // 判断radio表单元素;
				var inputname=obj.attr("name");
				var radiovalue=parentobj.find(":radio[name="+inputname+"]:checked").val();
				if(!radiovalue){
					errorobj=obj;
					this.showmsg(errormsg,tiptype,{obj:obj},show);
					return false;
				}
				errorobj=null;
				this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
				return "radio";
			}

			if(obj.is("[datatype='checkbox']")){  // 判断checkbox表单元素;
				var inputname=obj.attr("name");
				var checkboxvalue=parentobj.find(":checkbox[name="+inputname+"]:checked").val();
				if(!checkboxvalue){
					errorobj=obj;
					this.showmsg(errormsg,tiptype,{obj:obj},show);
					return false;
				}
				errorobj=null;
				this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
				return "checkbox";
			}

			if(obj.is("[datatype='select']")){  // 判断select表单元素;
				if(!obj.val()){
				  errorobj=obj;
				  this.showmsg(errormsg,tiptype,{obj:obj},show);
				  return false;
				}
				errorobj=null;
				this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
				return "select";
			}
			
			var defaultvalue=obj.attr("tip");
			if((obj.val()==="" || obj.val()===defaultvalue) && obj.attr("ignore")!="ignore"){
				errorobj=obj;
				this.showmsg(obj.attr("nullmsg") || tipmsg.s,tiptype,{obj:obj},show);
				return false;
			}
			
			if(obj.attr("recheck")){
				var theother=parentobj.find("input[name="+obj.attr("recheck")+"]:first");
				if(obj.val()!=theother.val()){
					errorobj=obj;
					this.showmsg(errormsg,tiptype,{obj:obj},show);
					return false;
				}
			}
			if(obj.attr("alternative")){ //二选一
				var theother=parentobj.find("textarea[name="+obj.attr("alternative")+"]:first");
				if(theother.val()==undefined){
					theother=parentobj.find("input[name="+obj.attr("alternative")+"]:first");
				}
				if(theother.val()==""&&obj.val()==""){
					errorobj=obj;
					theother.addClass("Validform_error");
					this.showmsg("二选一必填",tiptype,{obj:obj},show);
					this.showmsg("二选一必填",tiptype,{obj:theother},show);
					return false;
				}
				if(obj.val()!=""){
					this.showmsg(tipmsg.r,tiptype,{obj:theother,type:2},"hide");
					theother.removeClass("Validform_error");
				}
				if(theother.val()!=""){
					this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
				}
			}
			if(obj.attr("greaterthan")){//对比两个数字,它比前一个小
				var theother=parentobj.find("input[name="+obj.attr("greaterthan")+"]:first");
				var thisValue=parseInt(obj.val());
				var otherValue=parseInt(theother.val());
				if(!isNaN(thisValue) && !isNaN(otherValue) && thisValue>=otherValue){// 都是数字,大于时报错
					errorobj=obj;
					this.showmsg("要小于上限",tiptype,{obj:obj},show);
					return false;
				}else if(!isNaN(thisValue) && !isNaN(otherValue) && thisValue<otherValue){
					this.showmsg(tipmsg.r,tiptype,{obj:theother,type:2},"hide");
					this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
					obj.removeClass("Validform_error");
					theother.removeClass("Validform_error");
				}
				
			}
			if(obj.attr("lessthan")){  //对比两个数字,它比前一个大
				var theother=parentobj.find("input[name="+obj.attr("lessthan")+"]:first");
				var thisValue=parseInt(obj.val());
				var otherValue=parseInt(theother.val());
				if(!isNaN(thisValue) && !isNaN(otherValue) && thisValue<=otherValue){// 都是数字,小于时报错
					errorobj=obj;
					this.showmsg("要大于下限",tiptype,{obj:obj},show);
					return false;
				}else if(!isNaN(thisValue) && !isNaN(otherValue) && thisValue>otherValue){
					this.showmsg(tipmsg.r,tiptype,{obj:theother,type:2},"hide");
					this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
					obj.removeClass("Validform_error");
					theother.removeClass("Validform_error");
				}
				
			}
			
			if(obj.attr("greatertime")){  //对比两个日期,它比前一个大
				var theother=parentobj.find("input[name="+obj.attr("greatertime")+"]:first");
				var thisValue=StrToTime(obj.val());
				var otherValue=StrToTime(theother.val());
		        
				if( thisValue<otherValue){
					errorobj=obj;
					this.showmsg("要大于",tiptype,{obj:obj},show);
					alert("开始时间要大于结束时间");
					return false;
				}else if(thisValue>=otherValue){
					this.showmsg(tipmsg.r,tiptype,{obj:theother,type:2},"hide");
					this.showmsg(tipmsg.r,tiptype,{obj:obj,type:2},"hide");
					obj.removeClass("Validform_error");
					theother.removeClass("Validform_error");
				}
				
			}
			
			obj.removeClass("Validform_error");
			errorobj=null;
			return true;
		}
		
	};
	function StrToTime(thisValue){
		 var arys= thisValue.split('-');     
         var d = new Date(arys[0], parseInt(arys[1])-1, arys[2]);   
         return  d.getTime();    
	}
	// 公用方法显示&关闭信息提示框;
	$.Showmsg=function(msg){
		creatMsgbox();
		$.fn.Validform.sn.showmsg(msg,1);
	};
	$.Hidemsg=function(){
		msgobj.hide();
		msghidden=true;
	};

})(jQuery);

 

     css:

* {
	margin: 0;
	padding: 0;
}

input,select,textarea {
	font-size: 1em;
	margin: 0;
	color: #000;
	font-family: tahoma, arial, simsun, sans-serif;
}

table {
	border-collapse: collapse;
	border-spacing: 0;
}

:focus {
	outline: none;
}

body {
	font: 12px/1.5 tahoma, arial, \5b8b\4f53, sans-serif;
}
/* registerform */
.registerform .need {
	width: 10px;
	color: #b20202;
}

.registerform td {
	padding: 5px 0;
	vertical-align: top;
	text-align: left;
}

.registerform .inputxt,.registerform textarea {
	border: 1px solid #a5aeb6;
	width: 196px;
	padding: 2px;
}

.registerform textarea {
	height: 75px;
}

.registerform label {
	margin: 0 26px 0 10px;
}

.registerform .tip {
	line-height: 20px;
	color: #5f6a72;
}

.registerform select {
	width: 202px;
}

.registerformalter select {
	width: 124px;
}
/*==========以下部分是必须的===========*/
.Validform_checktip {
	margin-left: 8px;
	line-height: 20px;
	height: 20px;
	overflow: hidden;
	color: #999;
	font-size: 12px;
}

.Validform_right {
	color: #71b83d;
	padding-left: 20px;
	background: url(../images/right.png) no-repeat left center;
}

.Validform_wrong {
	color: red;
	padding-left: 20px;
	white-space: nowrap;
	background: url(../images/error.png) no-repeat left center;
}

.Validform_loading {
	padding-left: 20px;
	background: url(../images/onLoad.gif) no-repeat left center;
}

.Validform_error {
	background-color: #ffe7e7;
}

#Validform_msg {
	color: #7d8289;
	font: 12px/1.5 tahoma, arial, \5b8b\4f53, sans-serif;
	width: 280px;
	background: #fff;
	position: absolute;
	top: 0px;
	right: 50px;
	z-index: 99999;
	display: none;
	filter: progid :   DXImageTransform.Microsoft.Shadow (   Strength =   3,
		Direction =   135, Color =   '#999999' );
	-webkit-box-shadow: 2px 2px 3px #aaa;
	-moz-box-shadow: 2px 2px 3px #aaa;
}

#Validform_msg .iframe {
	position: absolute;
	left: 0px;
	top: -1px;
	z-index: -1;
}

#Validform_msg .Validform_title {
	line-height: 25px;
	height: 25px;
	text-align: left;
	font-weight: bold;
	padding: 0 8px;
	color: #fff;
	position: relative;
	background-color: #000;
}

#Validform_msg a.Validform_close:link,#Validform_msg a.Validform_close:visited
	{
	line-height: 22px;
	position: absolute;
	right: 8px;
	top: 0px;
	color: #fff;
	text-decoration: none;
}

#Validform_msg a.Validform_close:hover {
	color: #cc0;
}

#Validform_msg .Validform_info {
	padding: 8px;
	border: 1px solid #000;
	border-top: none;
	text-align: left;
}

    jsp

  

<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags/form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script src="resources/jquery/1.10.2/jquery.json-2.4.js"></script>
<script class="jsbin"
	src="resources/jquery/1.10.2/jquery.dataTables.nightly.js"></script>
<script class="jsbin"
	src="resources/jquery/1.10.2/jquery.dataTables.nightly.js"></script>
<style type="text/css" title="currentStyle">
@import "${projectPath}/resources/datatables/css/demo_page.css";

@import "${projectPath}/resources/datatables/css/demo_table.css";

@import "${projectPath}/resources/datatables/css/demo_table_jui.css";
</style>
<script type="text/javascript"
	src="resources/tableValidation/tableValid.js"></script>
<script type="text/javascript">
	$(function() {
		$(".aa:last").Validform({
			tiptype : 2,
			callback : function(data) {
				if (data.status == "y") {
					setTimeout(function() {
						$.Hidemsg();
					}, 2000);
				}
			}
		});
	})
</script>
<style type="text/css">
@import "${projectPath}/resources/tableValidation/valid.css";
</style>
<script type="text/javascript">
	
</script>
<div class="container">
	<s:form action="addchannelbandwidthalarm" method="post"
		modelAttribute="channelalarm" class="aa">
		<div class="row">
			<table id="add" class="table table-hover"
				style="margin-left: auto; margin-right: auto; width: auto;">
				<tr>
					<td>频道名称:</td>
					<td><s:input path="channelname" class="form-control"
							placeholder="频道请从rcms中复制" datatype="channelname"
							nullmsg="请输入频道名称" errormsg="请在rcms中复制" /> <c:out
							value="${channelnameerror}"></c:out>
					</td>
					<td><div class="Validform_checktip">请输入频道名称</div>
					</td>
				</tr>
				<tr>
					<td>告警上限:</td>
					<td><s:input path="uplimit" class="form-control"
							placeholder="单位(MB)" datatype="positiveinteger" nullmsg="请输入告警上限"
							errormsg="请输入正整数" /></td>
					<td><div class="Validform_checktip">请输入正整数</div>
					</td>
				</tr>
				<tr>
					<td>告警下限:</td>
					<td><s:input path="downlimit" class="form-control"
							placeholder="单位(MB)" datatype="*" greaterthan="uplimit"
						    nullmsg="请输入告警下限" errormsg="请输入正整数,并小于上限" />
					</td>
					<td><div class="Validform_checktip">请输入正整数</div>
					</td>
				</tr>
				<tr>
					<td>延迟时间:</td>
					<td><s:select path="delay_time" class="form-control">
							<s:option value="5" label="5分钟" />
							<s:option value="10" label="10分钟" />
							<s:option value="15" label="15分钟" />
							<s:option value="30" label="30分钟" selected="selected" />
							<s:option value="45" label="45分钟" />
							<s:option value="60" label="60分钟" />
							<s:option value="120" label="2小时" />
						</s:select></td>
					<td><div class="Validform_checktip">延迟时间内有超量不会告警</div>
					</td>
				</tr>
				<tr>
					<td>告警间隔:</td>
					<td><s:select path="send_num" class="form-control">
							<s:option value="1" label="5分钟" />
							<s:option value="2" label="10分钟" />
							<s:option value="3" label="15分钟" />
							<s:option value="6" label="30分钟" />
							<s:option value="9" label="45分钟" />
							<s:option value="12" label="60分钟" />
							<s:option value="24" label="2小时" />
							<s:option value="120" label="12小时" />
						</s:select></td>
					<td><div class="Validform_checktip">持续达到告警值的告警间隔</div>
					</td>
				</tr>
				<tr>
					<td>客户邮箱:</td>
					<td><s:textarea class="form-control" rows="3" path="email"
							datatype="email" nullmsg="请输入email" errormsg="email格式错误" /></td>
					<td><div class="Validform_checktip">多个地址以英文逗号分隔</div>
					</td>
				</tr>
				<tr>
					<td>客户手机:</td>
					<td><s:textarea class="form-control" rows="3" path="sms"
							datatype="sms" nullmsg="请输入手机号" errormsg="格式错误" /></td>
					<td><div class="Validform_checktip">多个号码以英文逗号分隔</div>
					</td>
				</tr>
				<tr>
					<td>是否可用:</td>
					<td><s:select path="enable" class="form-control">
							<s:option value="0" label="可用" />
							<s:option value="1" label="不可用" />
						</s:select></td>
					<td><div class="Validform_checktip">是否生效</div>
					</td>
				</tr>
				<tr>
					<td><input type="submit" class="btn btn-default " value="提交" />
					</td>
					<td><a class="btn btn-default btn-sm" role="button"
						href="${pageContext.request.contextPath}/channelbandwidthalarm"
						title="返回">返回</a>
					</td>
					<td></td>
				</tr>
			</table>
		</div>
	</s:form>
</div>

 

分享到:
评论

相关推荐

    大学生毕设+基于SpringBoot和Vue、MyBatis带GUI界面+云音乐管理系统(前后端源码+数据库+环境搭建步骤)

    | Hibernator-Validator | 6.0.17 | 验证框架| | redisson | 3.10.6 | 对redis进行封装、集成分布式锁等 | | hikari | 3.2.0| 数据库连接池| | log4j2 | 2.11.2 | 更快的log日志工具 | | fst| 2.57 | 更快的序列化

    基于SSHI架构的开发平台技术方案

    包括:表格控件,树形菜单,树形表格,弹出框,对话框,选项卡,日期组件、日历组件、图表组件、报表组件、表单验证框架等 平台集成系统管理模块,包括:(1)服务器系统信息监控 (2)组织机构管理 (3)用户管理 (4)角色...

    mall项目是一套电商系统,包括前台商城系统及后台管理系统.zip

    如果您正在寻找一个现代化、高效且易于扩展的开发框架,那么这个SpringBoot项目将是您的理想选择。 主要特点: 快速开发:SpringBoot通过自动配置和约定大于配置的原则,大大简化了项目设置和开发过程。 易于扩展...

    最新基于SSM框架ssm高校四六级报名管理系统.zip

    该系统采用Spring、SpringMVC和MyBatis(SSM)集成框架开发,旨在提高报名管理效率,简化管理员和学生的工作流程。 系统的主要功能分为管理员端和学生端: **管理员端**: 1. **个人中心**:管理员可以管理自己的...

    毕业设计之SpringBoot结合uni-app(vue)开发二手图书商城微信小程序和app

    该系统的设计是采用前后端分离的开发模式,后端采用Spring Boot的集成开发框架,数据库是MySQL,app端是采用最近流行的跨平台开发框架uni-app,PC端是采用Vue加ElementUI的开发框架,开发工具为IntelliJ IDEA ...

    NutzWk企业级开源开发框架

    NutzWk是集成了Shiro权限控制、Ehcache缓存、Redis、Email服务、Quartz定时任务、Lucene搜索引擎、Beetl/Velocity模板引擎等技术的开源企业级开发框架。 NutzWk 3.x 运行环境: 1、JDK 8 2、Tomcat 8 3、Maven ...

    ThinkPHP3.2仿京东商城视频教程实战课程,ThinkPHP3.2开发大型商城项目实战视频

    一、ThinkPHP3.2仿京东实战电子商城开发项目 第一天 1.项目说明 2.时间插件、XSS过滤、在线编辑器使用 3.商品的删除 4.商品的修改完成-一张表的操作全部完成 5.tp中使用AJAX提交表单 ...12-RBAC-tp框架使用jquery

    基于J2EE框架的个人博客系统项目毕业设计论...

    它使用服务层框架可以将JavaBeans从Jsp/Servlet中分离出来,而使用表现层框架则可以将Jsp中剩余的JavaBeans完全分离,这部分JavaBeans主要负责显示相关信息,一般是通过标签库(Taglib)实现,不同框架有不同自己的...

    JAVA毕业设计之springboot网上图书商城项目(springboot完整源码+说明).zip

    该项目基于Spring Boot框架开发,实现了一个完整的网上图书商城系统,包括前台展示、用户注册登录、购物车管理、订单管理、图书分类管理等功能。项目中使用了Spring Boot、Spring MVC、MyBatis等技术,整体架构清晰...

    CRM客户关系管理系统(配套数据库需另行下载).zip

    前端:vue+element框架 后台:spring+springMVC+Mybatis框架 开发软件:idea 数据库:MySQL 1.shiro身份验证,权限管理。 主要是授权,在项目启动的时候会加载所有的权限资源,登录然后进行权限判断,通过后台代码...

    4S店管理系统.zip

    前端:vue+element框架 后台:spring+springMVC+Mybatis框架 开发软件:idea 数据库:MySQL 1.shiro身份验证,权限管理。 主要是授权,在项目启动的时候会加载所有的权限资源,登录然后进行权限判断,通过后台代码...

    基于J2EE框架的个人博客系统项目毕业设计论文(源码和论文)

    它使用服务层框架可以将JavaBeans从Jsp/Servlet中分离出来,而使用表现层框架则可以将Jsp中剩余的JavaBeans完全分离,这部分JavaBeans主要负责显示相关信息,一般是通过标签库(Taglib)实现,不同框架有不同自己的...

    网络书店源码三层架构,数据库操作

    网络书店v1.1源码 网站名称:网络书店 版本:v1.1 开发工具:Visual Studio ...4)web.config:数据库链接新增windows集成验证(无需账号密码) 好消息:微软Teched2011技术大会门票6折(截至2011-8-12日)+好礼相送~

    我记录网站综合系统 1.6源码

    4)和门户集成,可以直接导入门户app中。 框架部分新增 editor:工具栏增加flash按钮 mvc:增加验证码控件,简化验证码使用 mvc:美化弹窗效果,边框使用透明背景,优化了 loading 框 mvc:增加 ...

    网络书店v1.1源码(三层、附设计文档)

    4)web.config:数据库链接新增windows集成验证(无需账号密码) 网站名称:网络书店 版本:v1.1 开发工具:Visual Studio 2008 开发语言:C# 开发框架:.NetFramework 2.0 数据库:sql server 2005 其他:借鉴...

    基于SpringBoot+Shiro+Redis+Jwt+Thymeleaf+MyBatis 开发的后台用户、角色+源代码+文档

    * 最近学习了远程过程调用协议RPC(Remote Procedure Call Protocol),将本框架与dubbo做了一个集成,详见dubbo分支, * 为了方便大学家习dubbo的运行机制,本框架将dubbo的provider和customer作了一个整合,将官方...

    JAVA程序开发大全---上半部分

    20.5.6 验证用户登录信息的Servlet类login 360 20.6 显示宠物信息模块的实现 363 20.6.1 对应宠物的实体类User 363 20.6.2 定义对宠物信息进行数据库操作的业务逻辑类PetBuy 363 20.6.3 分页显示系统中销售的所有...

    火炬博客系统5

    Spring框架是轻量级组件部署和运行的容器,可以很好的支持AOP(面向切面编程)的开发模式,Spring能有效地组织中间层对象,通过Bean容器为业务对象、DAO对象和资源对象提供了IOC类型的装配能力,将Struts和Hibernate...

    火炬博客系统7

    Spring框架是轻量级组件部署和运行的容器,可以很好的支持AOP(面向切面编程)的开发模式,Spring能有效地组织中间层对象,通过Bean容器为业务对象、DAO对象和资源对象提供了IOC类型的装配能力,将Struts和Hibernate...

    火炬博客系统6

    Spring框架是轻量级组件部署和运行的容器,可以很好的支持AOP(面向切面编程)的开发模式,Spring能有效地组织中间层对象,通过Bean容器为业务对象、DAO对象和资源对象提供了IOC类型的装配能力,将Struts和Hibernate...

Global site tag (gtag.js) - Google Analytics