事件域名: $(dom).on('click.myNameSpace',function(){ ... }),其中‘.myNameSpace’便是域名;

      目前作用:$(dom).off('click.myNameSpace'),解绑指定的域名事件,其他绑定的click逻辑依旧正常。

1、extension.js:

// extend the [phone,idCard,date,time,radio,checkbox] rules
$.extend($.fn.validatebox.defaults.rules, {
phone: {
validator: function(value,param){
if(!(/^1[34578]\d{9}$/.test(value))) return false;
return true;
},
message: 'Field do not match.'
},
idCard: {
validator: function(value,param){
var reg = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
if(reg.test(value)) return true;
return false;
},
message: 'Field do not match.'
},
date: {
validator: function(value,param){
var reg = /((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))/;
if(reg.test(value)) return true;
return false;
},
message: 'Field do not match.'
},
time: {
validator: function(value,param){
var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$/;
if(reg.test(value)){
return true;
}
return false;
},
message: 'Field do not match.'
},
radio: {
validator: function(value, param){
var input = $(param[0]),status = false,firstObj = $(input[0]),
cntObj = firstObj.parent(),initCount = cntObj.attr("initCount") || 0;
input.off('.radio').on('click.radio',function(){
$(this).focus();
try{ cntObj.tooltip('hide'); }catch(e){}
});
cntObj.off("mouseover mouseout").on("mouseover mouseout",function(event){
var bool = input.validatebox('isValid');
if(event.type == "mouseover"){
if(bool) try{ cntObj.tooltip('hide'); }catch(e){}
else try{ cntObj.tooltip('show');}catch(e){}
}else if(event.type == "mouseout") try{ cntObj.tooltip('hide'); }catch(e){}
});
if(initCount-1<0){
tipProcess(firstObj,"initCount");
initCount ++ ;
}
status = $(param[0] + ':checked').val() != undefined;
return status;
},
message: 'Please choose option for {1}.'
},
checkbox: {
validator: function (value, param) {
var inputs = $(param[0]), maxNum = param[1], checkNum = 0,status=false,
firstObj = $(inputs[0]),cntObj = firstObj.parent(),initCount = cntObj.attr("initCount") || 0;
inputs.each(function () {
if (this.checked) checkNum++;
});
inputs.off('.checkbox').on('click.checkbox',function(){
//$(this).focus();
var bool = inputs.validatebox('isValid');
if(bool) try{ cntObj.tooltip('hide'); }catch(e){}
else try{ cntObj.tooltip('show');}catch(e){}
});
cntObj.off("mouseover mouseout").on("mouseover mouseout",function(event){
var bool = inputs.validatebox('isValid');
if(event.type == "mouseover"){
if(bool) try{ cntObj.tooltip('hide'); }catch(e){}
else try{ cntObj.tooltip('show');}catch(e){}
}else if(event.type == "mouseout") try{ cntObj.tooltip('hide'); }catch(e){}
});
if(initCount-1<0){
tipProcess(firstObj,"initCount");
initCount ++ ;
}
status = checkNum > 0 ;
return status;
},
message: 'Please choose options !'
}
});
function tipProcess(firstObj,countFlag){
var dataOps = firstObj.validatebox('options'),ctn=firstObj.parent(),
tipMsg = dataOps.missingMessage || dataOps.invalidMessage || firstObj.validatebox.defaults.rules.checkbox.message;
ctn.tooltip({ position: 'right', content: '<span style="color:#000">'+tipMsg+'</span>',
onShow: function(){
$(this).tooltip('tip').css({
backgroundColor: 'rgb(255, 255, 204)',
borderColor: 'rgb(204, 153, 51)'
});
}
}).tooltip('hide');
var initCount = 0;
if(countFlag) {
initCount = ctn.attr(countFlag);
initCount = initCount - 0 + 1;
ctn.attr(countFlag,initCount);
}
}

2、html:(相关资源自行引入)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Validate Form on Submit - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="css/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="css/icon.css">
<link rel="stylesheet" type="text/css" href="css/demo.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/extension/extension.js"></script>
<script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
<h2>Validate Form on Submit</h2>
<p>The form does not perform validation before being submitted.</p>
<div style="margin:20px 0;"></div>
<div class="easyui-panel" title="New Topic" style="width:400px">
<div style="padding:10px 60px 20px 60px">
<form id="ff" class="easyui-form" method="post" data-options="novalidate:true">
<table cellpadding="5">
<tr>
<td>Name:</td>
<td><input class="easyui-textbox" type="text" name="name" data-options="required:true"></input></td>
</tr>
<tr>
<td>Email:</td>
<td><input class="easyui-textbox" type="text" name="email" data-options="required:true,validType:'email'"></input></td>
</tr>
<tr>
<td>Subject:</td>
<td><input class="easyui-textbox" type="text" name="subject" data-options="required:true"></input></td>
</tr>
<tr>
<td>Message:</td>
<td>
<div>
<input class="easyui-validatebox" type="radio" name="yes_no" value="1" data-options="validType:'radio[\'#ff input[name=yes_no]\', \'Yes or no\']'">Yes
<input class="easyui-validatebox" type="radio" name="yes_no" value="0">No
</div>
</td>
</tr>
<tr>
<td>Language:</td>
<td>
<div>
<input type="checkbox" name="cb1" class="easyui-validatebox" value="1" validType="checkbox['#ff input[name=cb1]']"/>ck1
<input type="checkbox" name="cb1" class="easyui-validatebox" value="2"/>ck2
<input type="checkbox" name="cb1" class="easyui-validatebox" value="3" />ck3
<input type="checkbox" name="cb1" class="easyui-validatebox" value="4" />ck4
</div>
</td>
</tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">Clear</a>
</div>
</div> </div>
<script>
function submitForm(){
$('#ff').form('submit',{
onSubmit:function(){
return $(this).form('enableValidation').form('validate');
}
});
}
function clearForm(){
$('#ff').form('clear');
} </script>
</body>
</html>

easyui validate -- radio、checkbox 校验扩展,事件域名的更多相关文章

  1. JQuery触发radio或checkbox的change事件

    在JQuery中,当给radio或checkbox添加一个change事件时,如果它的值发生变化就会触发change事件;本文将详细介绍如何利用JQuery触发Checkbox的change事件需要了 ...

  2. radio与checkbox的选中事件

    <一>判断checkbox的选中事件 var result=$(this).find("input[type='checkbox']").prop("chec ...

  3. bootstrap+jQuery.validate表单校验

    谈谈表单校验 这大概是一种惯例,学习前台后台最开始接触的业务都是用户注册和登录.现在社会坚持以人为本的理念,在网站开发过程同样如此.User是我们面对较多的对象,也是较核心的对象.最开始的用户注册和登 ...

  4. jQuery.validate表单校验+bootstrap

    谈谈表单校验 这大概是一种惯例,学习前台后台最开始接触的业务都是用户注册和登录.现在社会坚持以人为本的理念,在网站开发过程同样如此.User是我们面对较多的对象,也是较核心的对象.最开始的用户注册和登 ...

  5. SQL Server 扩展事件(Extented Events)从入门到进阶(4)——扩展事件引擎——基本概念

    本文属于 SQL Server 扩展事件(Extented Events)从入门到进阶 系列 在第一二节中,我们创建了一些简单的.类似典型SQL Trace的扩展事件会话.在此过程中,介绍了很多扩展事 ...

  6. 微信小程序 - radio/checkbox自定义组件

    更新 2019-01-26:首次发布 2019-01-27:增加默认取值选中radio/checkbox,checkbox需在onload取值 2019-01-28:增加radio取值不存在红色提示和 ...

  7. SQLSERVER2012里的扩展事件初尝试(上)

    SQLSERVER2012里的扩展事件初尝试(上) SQLSERVER2012里的扩展事件初尝试(下) 周未看了这两篇文章: 扩展事件在Denali CTP3里的新UI(一) 扩展事件在Denali ...

  8. Solon详解(六)- Solon的校验扩展框架使用与扩展

    Solon详解系列文章: Solon详解(一)- 快速入门 Solon详解(二)- Solon的核心 Solon详解(三)- Solon的web开发 Solon详解(四)- Solon的事务传播机制 ...

  9. 利用扩展事件进行调优和Troubleshooting PPT分享

        本篇主题是我在2015年中国数据库大会(DTCC)上的分享,扩展事件从2008版本出来到现在已经有6-7年,国内却很少有相关资料和使用,现在分享一下PPT,希望对大家有所帮助.       可 ...

随机推荐

  1. ssm 连接两个数据库

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  2. Python __import__() 函数

     Python OS 文件/目录方法 Python 面向对象  Python __import__() 函数  Python 内置函数 描述 __import__() 函数用于动态加载类和函数 . 如 ...

  3. 【转】 UI自动化测试的关注点

    我发现了,大家极度关心自动化测试,尤其是UI自动化测试,虽然现在作为专项测试,离开这些越来越远了,但总能遥想以前,我总能想起自己做nokia的WindowsLive的ui自动化,做web的自动化测试, ...

  4. 唯品会海量实时OLAP分析技术升级之路

    本文转载自公众号 DBAplus社群 , 作者:谢麟炯 谢麟炯,唯品会大数据平台高级技术架构经理,主要负责大数据自助多维分析平台,离线数据开发平台及分析引擎团队的开发和管理工作,加入唯品会以来还曾负责 ...

  5. centos 7下部署grpc

    gRPC 是一个高性能.开源和通用的 RPC 框架,面向移动和 HTTP/2 设计.目前提供 C.Java 和 Go 语言版本,分别是:grpc, grpc-java, grpc-go. 其中 C 版 ...

  6. 20165315 C语言学习情况与Java学习目标

    20165315 C语言学习情况与Java学习目标 一.出色技能的获取经验 我从小便是一个中规中矩的人,在很多方面都是让成绩尽量保持在前百分之二十到三十这个范围内,比如我比较擅长的唱歌和乒乓球,但也不 ...

  7. LWP::UserAgent的用法

    LWP::UserAgent是一个模拟用户浏览器的类,在使用的时候需要遵守以下几步: 1.引入模块 2.创建一个LWP::UserAgent的对象 3.设置这个对象的相关参数 4.创建HTTP::Re ...

  8. Oracle性能优化2- 依据场景选择技术

    1.索引的坏处 索引可以加快查询效率,但是使用不当,会造成插入性能很低 drop table test1 purge; drop table test2 purge; drop table test3 ...

  9. Apache Commons configuration使用入门

    使用Commons  Configuration可以很好的管理我们的配置文件的读写, 官网:http://commons.apache.org/configuration 需要用到commons-la ...

  10. 体验godaddy域名转入,添加A记录,及使用dnspod的NS

    有两个域名一直放在朋友那,这个朋友是个神人,经常换电话号码,联系非常不方便. 近日将域名转入到godaddy下面了,第一次做域名转移,很是好奇. 之前域名在21.cn注册的,朋友帮我申请域名转出后,2 ...