[合并]与dev合并并修复了冲突
This commit is contained in:
commit
407591a253
143 files changed
+646
-27028
No files matched your search
@@ -11,29 +11,29 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
id: vm.contestList[vm.editingContestId-1].id,
|
||||
title: vm.editTitle,
|
||||
description: vm.editDescription,
|
||||
mode: vm.editMode,
|
||||
contest_type: 0,
|
||||
mode: vm.editMode,
|
||||
contest_type: 0,
|
||||
show_rank: vm.editShowRank,
|
||||
show_user_submission: vm.editShowSubmission,
|
||||
start_time: vm.editStartTime,
|
||||
end_time: vm.editEndTime,
|
||||
visible: vm.editVisible
|
||||
};
|
||||
if (vm.choseGroupList.length == 0) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
}
|
||||
if (vm.choseGroupList[0].id == 0) //everyone | public contest
|
||||
if (vm.password == "")
|
||||
ajaxData.contest_type = 1;
|
||||
else{
|
||||
ajaxData.password = vm.password;
|
||||
}
|
||||
else { // Add groups info
|
||||
ajaxData.groups = [];
|
||||
for (var i = 0; vm.choseGroupList[i]; i++)
|
||||
ajaxData.groups.push(parseInt(vm.choseGroupList[i].id))
|
||||
}
|
||||
end_time: vm.editEndTime,
|
||||
visible: vm.editVisible
|
||||
};
|
||||
if (vm.choseGroupList.length == 0) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
}
|
||||
if (vm.choseGroupList[0].id == 0) //everyone | public contest
|
||||
if (vm.password == "")
|
||||
ajaxData.contest_type = 1;
|
||||
else{
|
||||
ajaxData.password = vm.password;
|
||||
}
|
||||
else { // Add groups info
|
||||
ajaxData.groups = [];
|
||||
for (var i = 0; vm.choseGroupList[i]; i++)
|
||||
ajaxData.groups.push(parseInt(vm.choseGroupList[i].id))
|
||||
}
|
||||
|
||||
console.log(ajaxData);
|
||||
$.ajax({ // Add contest
|
||||
@@ -73,12 +73,12 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
choseGroupList: [],
|
||||
passwordUsable: false,
|
||||
keyword: "",
|
||||
editingContestId: 0,
|
||||
editTitle: "",
|
||||
editDescription: "",
|
||||
editProblemList: [],
|
||||
editPassword: "",
|
||||
editStartTime: "",
|
||||
editingContestId: 0,
|
||||
editTitle: "",
|
||||
editDescription: "",
|
||||
editProblemList: [],
|
||||
editPassword: "",
|
||||
editStartTime: "",
|
||||
editEndTime: "",
|
||||
editMode: "",
|
||||
editShowRank: false,
|
||||
@@ -109,36 +109,36 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
getPageData(page_index);
|
||||
},
|
||||
showEditContestArea: function (contestId) {
|
||||
if (contestId == vm.editingContestId)
|
||||
vm.editingContestId = 0;
|
||||
else {
|
||||
vm.editingContestId = contestId;
|
||||
vm.editTitle = vm.contestList[contestId-1].title;
|
||||
vm.editPassword = vm.contestList[contestId-1].password;
|
||||
vm.editStartTime = vm.contestList[contestId-1].start_time.substring(0,16).replace("T"," ");
|
||||
vm.editEndTime = vm.contestList[contestId-1].end_time.substring(0,16).replace("T"," ");
|
||||
vm.editMode = vm.contestList[contestId-1].mode;
|
||||
editVisible = vm.contestList[contestId-1].visible;
|
||||
vm.editChoseGroupList = [];
|
||||
for (var i = 0; i < vm.contestList[contestId-1].groups.length; i++){
|
||||
var id = parseInt(vm.contestList[contestId-1].groups[i]);
|
||||
var index = 0;
|
||||
for (; vm.groupList[index]; index++) {
|
||||
if (vm.groupList[index].id == id)
|
||||
break;
|
||||
}
|
||||
vm.groupList[index].chose = true;
|
||||
vm.choseGroupList.push({
|
||||
name:vm.groupList[i].name,
|
||||
index:index,
|
||||
id:id
|
||||
if (contestId == vm.editingContestId)
|
||||
vm.editingContestId = 0;
|
||||
else {
|
||||
vm.editingContestId = contestId;
|
||||
vm.editTitle = vm.contestList[contestId-1].title;
|
||||
vm.editPassword = vm.contestList[contestId-1].password;
|
||||
vm.editStartTime = vm.contestList[contestId-1].start_time.substring(0,16).replace("T"," ");
|
||||
vm.editEndTime = vm.contestList[contestId-1].end_time.substring(0,16).replace("T"," ");
|
||||
vm.editMode = vm.contestList[contestId-1].mode;
|
||||
editVisible = vm.contestList[contestId-1].visible;
|
||||
vm.editChoseGroupList = [];
|
||||
for (var i = 0; i < vm.contestList[contestId-1].groups.length; i++){
|
||||
var id = parseInt(vm.contestList[contestId-1].groups[i]);
|
||||
var index = 0;
|
||||
for (; vm.groupList[index]; index++) {
|
||||
if (vm.groupList[index].id == id)
|
||||
break;
|
||||
}
|
||||
vm.groupList[index].chose = true;
|
||||
vm.choseGroupList.push({
|
||||
name:vm.groupList[i].name,
|
||||
index:index,
|
||||
id:id
|
||||
});
|
||||
}
|
||||
vm.editShowRank = vm.contestList[contestId-1].show_rank;
|
||||
vm.editShowSubmission = vm.contestList[contestId-1].show_user_submission;
|
||||
editor("#editor").setValue(vm.contestList[contestId-1].description);
|
||||
vm.editingProblemContestIndex = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
showEditProblemArea: function(contestId) {
|
||||
if (vm.editingProblemContestIndex == contestId) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
require(["jquery", "bsAlert", "csrfToken"], function($, bsAlert, csrfTokenHeader){
|
||||
$("#contest-password-btn").click(function(){
|
||||
var password = $("#contest-password").val();
|
||||
if(!password){
|
||||
bsAlert("密码不能为空!");
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/contest/password/",
|
||||
data: {password: password, contest_id: location.href.split("/")[4]},
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
if(!data.code){
|
||||
location.reload();
|
||||
}
|
||||
else{
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
@@ -59,6 +59,7 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert"], function ($, codeMirro
|
||||
if(counter++ > 10){
|
||||
hideLoading();
|
||||
bsAlert("抱歉,服务器可能出现了故障,请稍后到我的提交列表中查看");
|
||||
counter = 0;
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
@@ -73,6 +74,7 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert"], function ($, codeMirro
|
||||
setTimeout(getResult, 1000);
|
||||
}
|
||||
else {
|
||||
counter = 0;
|
||||
hideLoading();
|
||||
$("#result").html(getResultHtml(data.data));
|
||||
}
|
||||
|
||||
+21
-28
@@ -3,47 +3,40 @@
|
||||
baseUrl: "js/",
|
||||
// 第三方脚本模块的别名,jquery比libs/jquery-1.11.1.min.js简洁明了;
|
||||
paths: {
|
||||
//百度webuploader
|
||||
webuploader: "lib/webuploader/webuploader",
|
||||
|
||||
jquery: "empty:",
|
||||
jquery: "lib/jquery/jquery",
|
||||
avalon: "lib/avalon/avalon",
|
||||
editor: "utils/editor",
|
||||
uploader: "utils/uploader",
|
||||
validation: "utils/validation",
|
||||
code_mirror: "utils/code_mirror",
|
||||
login: "app/oj/account/login",
|
||||
"bs_alert": "utils/bs_alert",
|
||||
submit_code: "app/oj/problem/submit_code",
|
||||
formValidation: "utils/formValidation",
|
||||
codeMirror: "utils/codeMirror",
|
||||
bsAlert: "utils/bsAlert",
|
||||
problem: "app/oj/problem/problem",
|
||||
contest: "app/admin/contest/contest",
|
||||
csrfToken: "utils/csrfToken",
|
||||
admin: "app/admin/admin",
|
||||
chart: "lib/chart/Chart",
|
||||
tagEditor: "lib/tagEditor/jquery.tag-editor.min",
|
||||
jqueryUI: "lib/jqueryUI/jquery-ui",
|
||||
bootstrap: "lib/bootstrap/bootstrap",
|
||||
datetimePicker: "lib/datetime_picker/bootstrap-datetimepicker.zh-CN",
|
||||
validator: "lib/validator/validator",
|
||||
|
||||
//formValidation 不要在代码中单独使用,而是使用和修改utils/validation
|
||||
base: "lib/formValidation/base",
|
||||
helper: "lib/formValidation/helper",
|
||||
"language/zh_CN": "lib/formValidation/language/zh_CN",
|
||||
"framework/bootstrap": "lib/formValidation/framework/bootstrap",
|
||||
"validator/notEmpty": "lib/formValidation/validator/notEmpty",
|
||||
"validator/stringLength": "lib/formValidation/validator/stringLength",
|
||||
"validator/date": "lib/formValidation/validator/date",
|
||||
"validator/integer": "lib/formValidation/validator/integer",
|
||||
"validator/between": "lib/formValidation/validator/between",
|
||||
|
||||
//富文本编辑器 不要直接使用,而是使用上面的editor
|
||||
// ------ 下面写的都不要直接用,而是使用上面的封装版本 ------
|
||||
//富文本编辑器simditor -> editor
|
||||
simditor: "lib/simditor/simditor",
|
||||
"simple-module": "lib/simditor/module",
|
||||
"simple-hotkeys": "lib/simditor/hotkeys",
|
||||
"simple-uploader": "lib/simditor/uploader",
|
||||
|
||||
//code mirroe 代码编辑器
|
||||
_code_mirror: "lib/codeMirror/codemirror",
|
||||
code_mirror_clang: "lib/codeMirror/language/clike",
|
||||
//code mirror 代码编辑器 ->codeMirror
|
||||
_codeMirror: "lib/codeMirror/codemirror",
|
||||
codeMirrorClang: "lib/codeMirror/language/clike",
|
||||
|
||||
//bootstrap
|
||||
bootstrap: "lib/bootstrap/bootstrap",
|
||||
//百度webuploader -> uploader
|
||||
webUploader: "lib/webuploader/webuploader",
|
||||
|
||||
//
|
||||
"_datetimepicker": "lib/datetime_picker/bootstrap-datetimepicker",
|
||||
"datetimepicker": "lib/datetime_picker/bootstrap-datetimepicker.zh-CN"
|
||||
"_datetimePicker": "lib/datetime_picker/bootstrap-datetimepicker"
|
||||
|
||||
},
|
||||
shim: {
|
||||
|
||||
@@ -23,21 +23,6 @@ var require = {
|
||||
|
||||
|
||||
// ------ 下面写的都不要直接用,而是使用上面的封装版本 ------
|
||||
|
||||
//formValidation -> utils/validation
|
||||
base: "lib/formValidation/base",
|
||||
helper: "lib/formValidation/helper",
|
||||
"language/zh_CN": "lib/formValidation/language/zh_CN",
|
||||
"framework/bootstrap": "lib/formValidation/framework/bootstrap",
|
||||
"validator/notEmpty": "lib/formValidation/validator/notEmpty",
|
||||
"validator/stringLength": "lib/formValidation/validator/stringLength",
|
||||
"validator/date": "lib/formValidation/validator/date",
|
||||
"validator/integer": "lib/formValidation/validator/integer",
|
||||
"validator/between": "lib/formValidation/validator/between",
|
||||
"validator/confirm":"lib/formValidation/validator/confirm",
|
||||
"validator/remote":"lib/formValidation/validator/remote",
|
||||
"validator/emailAddress":"lib/formValidation/validator/emailAddress",
|
||||
|
||||
//富文本编辑器simditor -> editor
|
||||
simditor: "lib/simditor/simditor",
|
||||
"simple-module": "lib/simditor/module",
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap v3.3.5 (http://getbootstrap.com)
|
||||
* Copyright 2011-2015 Twitter, Inc.
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.5",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.5",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),a(c.target).is('input[type="radio"]')||a(c.target).is('input[type="checkbox"]')||c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.5",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&cLine truncated
|
||||
d.trigger("activate.bs.scrollspy")},b.prototype.clear=function(){a(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var d=a.fn.scrollspy;a.fn.scrollspy=c,a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=d,this},a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new c(this)),"string"==typeof b&&e[b]()})}var c=function(b){this.element=a(b)};c.VERSION="3.3.5",c.TRANSITION_DURATION=150,c.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a.Event("show.bs.tab",{relatedTarget:e[0]});if(e.trigger(f),b.trigger(g),!g.isDefaultPrevented()&&!f.isDefaultPrevented()){var h=a(d);this.activate(b.closest("li"),c),this.activate(h,h.parent(),function(){e.trigger({type:"hidden.bs.tab",relatedTarget:b[0]}),b.trigger({type:"shown.bs.tab",relatedTarget:e[0]})})}}},c.prototype.activate=function(b,d,e){function f(){g.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.5",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* !!!!!! dev-version and still in progress !!!!!!!
|
||||
* this plugin loads all required components
|
||||
* to start validaton process properly
|
||||
* How to use this:
|
||||
* include bsfvalidator according to the following pattern
|
||||
* bsfvalidator!LANG:VALIDATORS
|
||||
*
|
||||
* Options:
|
||||
* LANG - (optinal and single value) indicates which language will be used
|
||||
* VALIDATORS - (required) defines which validators should be used
|
||||
* Examples:
|
||||
* 1) bsfvalidator!ua_UA:notEmpty,stringLength,regexp,emailAddress
|
||||
* 2) bsfvalidator!notEmpty,stringLength,regexp,emailAddress
|
||||
* 3) bsfvalidator!notEmpty
|
||||
* There is simple requirejs based project in demo/amd folder
|
||||
*/
|
||||
define("bsfvalidator", ["base", "helper", "framework/bootstrap"], function (base) {
|
||||
var buildMap = [];
|
||||
function getDeps (name) {
|
||||
var parts = name.match(/((.*):)?(.*)/),
|
||||
lang = null,
|
||||
deps = [],
|
||||
all = [];
|
||||
if (parts.length === 4) {
|
||||
lang = parts[2];
|
||||
deps = parts[3].split(',');
|
||||
}
|
||||
if (parts.length === 3) {
|
||||
deps = parts[2].split(',');
|
||||
}
|
||||
for (var i = 0, len = deps.length; i < len; i++) {
|
||||
deps[i] = './validator/' + deps[i];
|
||||
}
|
||||
if (lang) {
|
||||
lang = './language/' + lang;
|
||||
all.push(lang);
|
||||
}
|
||||
all = all.concat(deps);
|
||||
return {
|
||||
lang: lang,
|
||||
deps: deps,
|
||||
all: all
|
||||
};
|
||||
}
|
||||
return {
|
||||
load: function (name, req, onLoad, config) {
|
||||
var deps = getDeps(name);
|
||||
req(deps.all, function () {
|
||||
onLoad(base);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,294 +0,0 @@
|
||||
/**
|
||||
* FormValidation (http://formvalidation.io)
|
||||
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class supports validating Bootstrap form (http://getbootstrap.com/)
|
||||
*/
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("framework/bootstrap", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.Framework.Bootstrap = function(element, options, namespace) {
|
||||
options = $.extend(true, {
|
||||
button: {
|
||||
selector: '[type="submit"]',
|
||||
// The class of disabled button
|
||||
// http://getbootstrap.com/css/#buttons-disabled
|
||||
disabled: 'disabled'
|
||||
},
|
||||
err: {
|
||||
// http://getbootstrap.com/css/#forms-help-text
|
||||
clazz: 'help-block',
|
||||
parent: '^(.*)col-(xs|sm|md|lg)-(offset-){0,1}[0-9]+(.*)$'
|
||||
},
|
||||
// This feature requires Bootstrap v3.1.0 or later (http://getbootstrap.com/css/#forms-control-validation).
|
||||
// Since Bootstrap doesn't provide any methods to know its version, this option cannot be on/off automatically.
|
||||
// In other word, to use this feature you have to upgrade your Bootstrap to v3.1.0 or later.
|
||||
//
|
||||
// Examples:
|
||||
// - Use Glyphicons icons:
|
||||
// icon: {
|
||||
// valid: 'glyphicon glyphicon-ok',
|
||||
// invalid: 'glyphicon glyphicon-remove',
|
||||
// validating: 'glyphicon glyphicon-refresh',
|
||||
// feedback: 'form-control-feedback'
|
||||
// }
|
||||
// - Use FontAwesome icons:
|
||||
// icon: {
|
||||
// valid: 'fa fa-check',
|
||||
// invalid: 'fa fa-times',
|
||||
// validating: 'fa fa-refresh',
|
||||
// feedback: 'form-control-feedback'
|
||||
// }
|
||||
icon: {
|
||||
valid: null,
|
||||
invalid: null,
|
||||
validating: null,
|
||||
feedback: 'form-control-feedback'
|
||||
},
|
||||
row: {
|
||||
// By default, each field is placed inside the <div class="form-group"></div>
|
||||
// http://getbootstrap.com/css/#forms
|
||||
selector: '.form-group',
|
||||
valid: 'has-success',
|
||||
invalid: 'has-error',
|
||||
feedback: 'has-feedback'
|
||||
}
|
||||
}, options);
|
||||
|
||||
FormValidation.Base.apply(this, [element, options, namespace]);
|
||||
};
|
||||
|
||||
FormValidation.Framework.Bootstrap.prototype = $.extend({}, FormValidation.Base.prototype, {
|
||||
/**
|
||||
* Specific framework might need to adjust the icon position
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {jQuery} $icon The icon element
|
||||
*/
|
||||
_fixIcon: function($field, $icon) {
|
||||
var ns = this._namespace,
|
||||
type = $field.attr('type'),
|
||||
field = $field.attr('data-' + ns + '-field'),
|
||||
row = this.options.fields[field].row || this.options.row.selector,
|
||||
$parent = $field.closest(row);
|
||||
|
||||
// Place it after the container of checkbox/radio
|
||||
// so when clicking the icon, it doesn't effect to the checkbox/radio element
|
||||
if ('checkbox' === type || 'radio' === type) {
|
||||
var $fieldParent = $field.parent();
|
||||
if ($fieldParent.hasClass(type)) {
|
||||
$icon.insertAfter($fieldParent);
|
||||
} else if ($fieldParent.parent().hasClass(type)) {
|
||||
$icon.insertAfter($fieldParent.parent());
|
||||
}
|
||||
}
|
||||
|
||||
// The feedback icon does not render correctly if there is no label
|
||||
// https://github.com/twbs/bootstrap/issues/12873
|
||||
if ($parent.find('label').length === 0) {
|
||||
$icon.addClass('fv-icon-no-label');
|
||||
}
|
||||
// Fix feedback icons in input-group
|
||||
if ($parent.find('.input-group').length !== 0) {
|
||||
$icon.addClass('fv-bootstrap-icon-input-group')
|
||||
.insertAfter($parent.find('.input-group').eq(0));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a tooltip or popover
|
||||
* It will be shown when focusing on the field
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} message The message
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_createTooltip: function($field, message, type) {
|
||||
var ns = this._namespace,
|
||||
$icon = $field.data(ns + '.icon');
|
||||
if ($icon) {
|
||||
switch (type) {
|
||||
case 'popover':
|
||||
$icon
|
||||
.css({
|
||||
'cursor': 'pointer',
|
||||
'pointer-events': 'auto'
|
||||
})
|
||||
.popover('destroy')
|
||||
.popover({
|
||||
container: 'body',
|
||||
content: message,
|
||||
html: true,
|
||||
placement: 'auto top',
|
||||
trigger: 'hover click'
|
||||
});
|
||||
break;
|
||||
|
||||
case 'tooltip':
|
||||
/* falls through */
|
||||
default:
|
||||
$icon
|
||||
.css({
|
||||
'cursor': 'pointer',
|
||||
'pointer-events': 'auto'
|
||||
})
|
||||
.tooltip('destroy')
|
||||
.tooltip({
|
||||
container: 'body',
|
||||
html: true,
|
||||
placement: 'auto top',
|
||||
title: message
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_destroyTooltip: function($field, type) {
|
||||
var ns = this._namespace,
|
||||
$icon = $field.data(ns + '.icon');
|
||||
if ($icon) {
|
||||
switch (type) {
|
||||
case 'popover':
|
||||
$icon
|
||||
.css({
|
||||
'cursor': '',
|
||||
'pointer-events': 'none'
|
||||
})
|
||||
.popover('destroy');
|
||||
break;
|
||||
|
||||
case 'tooltip':
|
||||
/* falls through */
|
||||
default:
|
||||
$icon
|
||||
.css({
|
||||
'cursor': '',
|
||||
'pointer-events': 'none'
|
||||
})
|
||||
.tooltip('destroy');
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_hideTooltip: function($field, type) {
|
||||
var ns = this._namespace,
|
||||
$icon = $field.data(ns + '.icon');
|
||||
if ($icon) {
|
||||
switch (type) {
|
||||
case 'popover':
|
||||
$icon.popover('hide');
|
||||
break;
|
||||
|
||||
case 'tooltip':
|
||||
/* falls through */
|
||||
default:
|
||||
$icon.tooltip('hide');
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_showTooltip: function($field, type) {
|
||||
var ns = this._namespace,
|
||||
$icon = $field.data(ns + '.icon');
|
||||
if ($icon) {
|
||||
switch (type) {
|
||||
case 'popover':
|
||||
$icon.popover('show');
|
||||
break;
|
||||
|
||||
case 'tooltip':
|
||||
/* falls through */
|
||||
default:
|
||||
$icon.tooltip('show');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Plugin definition
|
||||
* Support backward
|
||||
* @deprecated It will be removed soon. Instead of using $(form).bootstrapValidator(), use
|
||||
* $(form).formValidation({
|
||||
* framework: 'bootstrap' // It's equivalent to use data-fv-framework="bootstrap" for <form>
|
||||
* });
|
||||
*/
|
||||
$.fn.bootstrapValidator = function(option) {
|
||||
var params = arguments;
|
||||
return this.each(function() {
|
||||
var $this = $(this),
|
||||
data = $this.data('formValidation') || $this.data('bootstrapValidator'),
|
||||
options = 'object' === typeof option && option;
|
||||
if (!data) {
|
||||
data = new FormValidation.Framework.Bootstrap(this, $.extend({}, {
|
||||
events: {
|
||||
// Support backward
|
||||
formInit: 'init.form.bv',
|
||||
formError: 'error.form.bv',
|
||||
formSuccess: 'success.form.bv',
|
||||
fieldAdded: 'added.field.bv',
|
||||
fieldRemoved: 'removed.field.bv',
|
||||
fieldInit: 'init.field.bv',
|
||||
fieldError: 'error.field.bv',
|
||||
fieldSuccess: 'success.field.bv',
|
||||
fieldStatus: 'status.field.bv',
|
||||
localeChanged: 'changed.locale.bv',
|
||||
validatorError: 'error.validator.bv',
|
||||
validatorSuccess: 'success.validator.bv'
|
||||
}
|
||||
}, options), 'bv');
|
||||
|
||||
$this.addClass('fv-form-bootstrap')
|
||||
.data('formValidation', data)
|
||||
.data('bootstrapValidator', data);
|
||||
}
|
||||
|
||||
// Allow to call plugin method
|
||||
if ('string' === typeof option) {
|
||||
data[option].apply(data, Array.prototype.slice.call(params, 1));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.bootstrapValidator.Constructor = FormValidation.Framework.Bootstrap;
|
||||
|
||||
return FormValidation.Framework.Bootstrap;
|
||||
}));
|
||||
@@ -1,177 +0,0 @@
|
||||
/**
|
||||
* FormValidation (http://formvalidation.io)
|
||||
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class supports validating Foundation form (http://foundation.zurb.com/)
|
||||
*/
|
||||
/* global Foundation: false */
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("framework/foundation", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.Framework.Foundation = function(element, options) {
|
||||
options = $.extend(true, {
|
||||
button: {
|
||||
selector: '[type="submit"]',
|
||||
// The class for disabled button
|
||||
// http://foundation.zurb.com/docs/components/buttons.html#button-colors
|
||||
disabled: 'disabled'
|
||||
},
|
||||
err: {
|
||||
// http://foundation.zurb.com/docs/components/forms.html#error-states
|
||||
clazz: 'error',
|
||||
parent: '^.*((small|medium|large)-[0-9]+)\\s.*(columns).*$'
|
||||
},
|
||||
// Foundation doesn't support feedback icon
|
||||
icon: {
|
||||
valid: null,
|
||||
invalid: null,
|
||||
validating: null,
|
||||
feedback: 'fv-control-feedback'
|
||||
},
|
||||
row: {
|
||||
// http://foundation.zurb.com/docs/components/forms.html
|
||||
selector: '.row',
|
||||
valid: 'fv-has-success',
|
||||
invalid: 'error',
|
||||
feedback: 'fv-has-feedback'
|
||||
}
|
||||
}, options);
|
||||
|
||||
FormValidation.Base.apply(this, [element, options]);
|
||||
};
|
||||
|
||||
FormValidation.Framework.Foundation.prototype = $.extend({}, FormValidation.Base.prototype, {
|
||||
/**
|
||||
* Specific framework might need to adjust the icon position
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {jQuery} $icon The icon element
|
||||
*/
|
||||
_fixIcon: function($field, $icon) {
|
||||
var ns = this._namespace,
|
||||
type = $field.attr('type'),
|
||||
field = $field.attr('data-' + ns + '-field'),
|
||||
row = this.options.fields[field].row || this.options.row.selector,
|
||||
$parent = $field.closest(row);
|
||||
|
||||
if ('checkbox' === type || 'radio' === type) {
|
||||
var $next = $icon.next();
|
||||
if ($next.is('label')) {
|
||||
$icon.insertAfter($next);
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent.find('label').length === 0) {
|
||||
$icon.addClass('fv-icon-no-label');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a tooltip or popover
|
||||
* It will be shown when focusing on the field
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} message The message
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_createTooltip: function($field, message, type) {
|
||||
var that = this,
|
||||
$icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
$icon
|
||||
.attr('title', message)
|
||||
.css({
|
||||
'cursor': 'pointer'
|
||||
})
|
||||
.off('mouseenter.container.fv focusin.container.fv')
|
||||
.on('mouseenter.container.fv', function() {
|
||||
that._showTooltip($field, type);
|
||||
})
|
||||
.off('mouseleave.container.fv focusout.container.fv')
|
||||
.on('mouseleave.container.fv focusout.container.fv', function() {
|
||||
that._hideTooltip($field, type);
|
||||
});
|
||||
Foundation.libs.tooltip.create($icon);
|
||||
$icon.data('fv.foundation.tooltip', $icon);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_destroyTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
$icon.css({
|
||||
'cursor': ''
|
||||
});
|
||||
var $tooltip = $icon.data('fv.foundation.tooltip');
|
||||
if ($tooltip) {
|
||||
// Foundation doesn't provide method to destroy particular tooltip instance
|
||||
$tooltip.off('.fndtn.tooltip');
|
||||
Foundation.libs.tooltip.hide($tooltip);
|
||||
$icon.removeData('fv.foundation.tooltip');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_hideTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
$icon.css({
|
||||
'cursor': ''
|
||||
});
|
||||
var $tooltip = $icon.data('fv.foundation.tooltip');
|
||||
if ($tooltip) {
|
||||
Foundation.libs.tooltip.hide($tooltip);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_showTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
var $tooltip = $icon.data('fv.foundation.tooltip');
|
||||
if ($tooltip) {
|
||||
$icon.css({
|
||||
'cursor': 'pointer'
|
||||
});
|
||||
Foundation.libs.tooltip.show($tooltip);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return FormValidation.Framework.Foundation;
|
||||
}));
|
||||
@@ -1,78 +0,0 @@
|
||||
/**
|
||||
* FormValidation (http://formvalidation.io)
|
||||
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class supports validating Pure framework (http://purecss.io/)
|
||||
*/
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("framework/pure", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.Framework.Pure = function(element, options) {
|
||||
options = $.extend(true, {
|
||||
button: {
|
||||
selector: '[type="submit"]',
|
||||
// The class of disabled button
|
||||
// http://purecss.io/buttons/#disabled-buttons
|
||||
disabled: 'pure-button-disabled'
|
||||
},
|
||||
err: {
|
||||
clazz: 'fv-help-block',
|
||||
parent: '^.*pure-control-group.*$'
|
||||
},
|
||||
// Pure doesn't support feedback icon
|
||||
icon: {
|
||||
valid: null,
|
||||
invalid: null,
|
||||
validating: null,
|
||||
feedback: 'fv-control-feedback'
|
||||
},
|
||||
row: {
|
||||
// http://purecss.io/forms/#aligned-form
|
||||
selector: '.pure-control-group',
|
||||
valid: 'fv-has-success',
|
||||
invalid: 'fv-has-error',
|
||||
feedback: 'fv-has-feedback'
|
||||
}
|
||||
}, options);
|
||||
|
||||
FormValidation.Base.apply(this, [element, options]);
|
||||
};
|
||||
|
||||
FormValidation.Framework.Pure.prototype = $.extend({}, FormValidation.Base.prototype, {
|
||||
/**
|
||||
* Specific framework might need to adjust the icon position
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {jQuery} $icon The icon element
|
||||
*/
|
||||
_fixIcon: function($field, $icon) {
|
||||
var ns = this._namespace,
|
||||
type = $field.attr('type'),
|
||||
field = $field.attr('data-' + ns + '-field'),
|
||||
row = this.options.fields[field].row || this.options.row.selector,
|
||||
$parent = $field.closest(row);
|
||||
|
||||
if ($parent.find('label').length === 0) {
|
||||
$icon.addClass('fv-icon-no-label');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return FormValidation.Framework.Pure;
|
||||
}));
|
||||
@@ -1,177 +0,0 @@
|
||||
/**
|
||||
* FormValidation (http://formvalidation.io)
|
||||
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class supports validating SemanticUI form (http://semantic-ui.com/)
|
||||
*/
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("framework/semantic", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.Framework.Semantic = function(element, options) {
|
||||
options = $.extend(true, {
|
||||
button: {
|
||||
selector: '[type="submit"]',
|
||||
// CSS class of disabled button
|
||||
// http://semantic-ui.com/elements/button.html#disabled
|
||||
disabled: 'disabled'
|
||||
},
|
||||
control: {
|
||||
valid: '',
|
||||
invalid: ''
|
||||
},
|
||||
err: {
|
||||
// http://semantic-ui.com/elements/label.html#pointing
|
||||
clazz: 'ui red pointing label transition',
|
||||
parent: '^.*(field|column).*$'
|
||||
},
|
||||
// When using feedback icon, the input must place inside 'ui input icon' element
|
||||
// <div class="ui input icon">
|
||||
// <input type="text" />
|
||||
// </div>
|
||||
// See http://semantic-ui.com/elements/input.html#icon
|
||||
icon: {
|
||||
// http://semantic-ui.com/elements/icon.html
|
||||
valid: null, // 'checkmark icon'
|
||||
invalid: null, // 'remove icon'
|
||||
validating: null, // 'refresh icon'
|
||||
feedback: 'fv-control-feedback'
|
||||
},
|
||||
row: {
|
||||
// http://semantic-ui.com/collections/form.html
|
||||
selector: '.field',
|
||||
valid: 'fv-has-success',
|
||||
invalid: 'error',
|
||||
feedback: 'fv-has-feedback'
|
||||
}
|
||||
}, options);
|
||||
|
||||
FormValidation.Base.apply(this, [element, options]);
|
||||
};
|
||||
|
||||
FormValidation.Framework.Semantic.prototype = $.extend({}, FormValidation.Base.prototype, {
|
||||
/**
|
||||
* Specific framework might need to adjust the icon position
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {jQuery} $icon The icon element
|
||||
*/
|
||||
_fixIcon: function($field, $icon) {
|
||||
var type = $field.attr('type');
|
||||
if ('checkbox' === type || 'radio' === type) {
|
||||
var $fieldParent = $field.parent();
|
||||
if ($fieldParent.hasClass(type)) {
|
||||
$icon.insertAfter($fieldParent);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a tooltip or popover
|
||||
* It will be shown when focusing on the field
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} message The message
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_createTooltip: function($field, message, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
// Remove the popup if it's already exists
|
||||
if ($icon.popup('exists')) {
|
||||
$icon.popup('remove popup')
|
||||
.popup('destroy');
|
||||
}
|
||||
|
||||
// http://semantic-ui.com/modules/popup.html
|
||||
switch (type) {
|
||||
case 'popover':
|
||||
$icon
|
||||
.css({
|
||||
'cursor': 'pointer'
|
||||
})
|
||||
.popup({
|
||||
content: message,
|
||||
position: 'top center'
|
||||
});
|
||||
break;
|
||||
|
||||
case 'tooltip':
|
||||
/* falls through */
|
||||
default:
|
||||
$icon
|
||||
.css({
|
||||
'cursor': 'pointer'
|
||||
})
|
||||
.popup({
|
||||
content: message,
|
||||
position: 'top center',
|
||||
variation: 'inverted'
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_destroyTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon && $icon.popup('exists')) {
|
||||
$icon
|
||||
.css({
|
||||
'cursor': ''
|
||||
})
|
||||
.popup('remove popup')
|
||||
.popup('destroy');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_hideTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
$icon.popup('hide');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_showTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
$icon.popup('show');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return FormValidation.Framework.Semantic;
|
||||
}));
|
||||
@@ -1,179 +0,0 @@
|
||||
/**
|
||||
* FormValidation (http://formvalidation.io)
|
||||
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class supports validating UIKit form (http://getuikit.com/)
|
||||
*/
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("framework/uikit", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.Framework.UIKit = function(element, options) {
|
||||
options = $.extend(true, {
|
||||
button: {
|
||||
selector: '[type="submit"]',
|
||||
// The class for disabled button
|
||||
// http://getuikit.com/docs/button.html
|
||||
disabled: 'disabled'
|
||||
},
|
||||
control: {
|
||||
valid: 'uk-form-success',
|
||||
invalid: 'uk-form-danger'
|
||||
},
|
||||
err: {
|
||||
// http://getuikit.com/docs/text.html#text-styles
|
||||
clazz: 'uk-text-danger',
|
||||
parent: '^.*(uk-form-controls|uk-width-[\\d+]-[\\d+]).*$'
|
||||
},
|
||||
// UIKit doesn't support feedback icon
|
||||
icon: {
|
||||
valid: null,
|
||||
invalid: null,
|
||||
validating: null,
|
||||
feedback: 'fv-control-feedback'
|
||||
},
|
||||
row: {
|
||||
// http://getuikit.com/docs/form.html
|
||||
selector: '.uk-form-row',
|
||||
valid: 'fv-has-success',
|
||||
invalid: 'fv-has-error',
|
||||
feedback: 'fv-has-feedback'
|
||||
}
|
||||
}, options);
|
||||
|
||||
FormValidation.Base.apply(this, [element, options]);
|
||||
};
|
||||
|
||||
FormValidation.Framework.UIKit.prototype = $.extend({}, FormValidation.Base.prototype, {
|
||||
/**
|
||||
* Specific framework might need to adjust the icon position
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {jQuery} $icon The icon element
|
||||
*/
|
||||
_fixIcon: function($field, $icon) {
|
||||
var ns = this._namespace,
|
||||
type = $field.attr('type'),
|
||||
field = $field.attr('data-' + ns + '-field'),
|
||||
row = this.options.fields[field].row || this.options.row.selector,
|
||||
$parent = $field.closest(row);
|
||||
|
||||
if ('checkbox' === type || 'radio' === type) {
|
||||
var $fieldParent = $field.parent();
|
||||
if ($fieldParent.is('label')) {
|
||||
$icon.insertAfter($fieldParent);
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent.find('label').length === 0) {
|
||||
$icon.addClass('fv-icon-no-label');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a tooltip or popover
|
||||
* It will be shown when focusing on the field
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} message The message
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_createTooltip: function($field, message, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
// Remove the tooltip if it's already exists
|
||||
if ($icon.data('tooltip')) {
|
||||
$icon.data('tooltip').off();
|
||||
$icon.removeData('tooltip');
|
||||
}
|
||||
|
||||
$icon
|
||||
.attr('title', message)
|
||||
.css({
|
||||
'cursor': 'pointer'
|
||||
});
|
||||
|
||||
new $.UIkit.tooltip($icon);
|
||||
// UIKit auto set the 'tooltip' data for the element
|
||||
// so I can retrieve the tooltip later via $icon.data('tooltip')
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_destroyTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
var tooltip = $icon.data('tooltip');
|
||||
if (tooltip) {
|
||||
tooltip.hide();
|
||||
tooltip.off();
|
||||
$icon.off('focus mouseenter')
|
||||
.removeData('tooltip');
|
||||
}
|
||||
$icon.css({
|
||||
'cursor': ''
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_hideTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
var tooltip = $icon.data('tooltip');
|
||||
if (tooltip) {
|
||||
tooltip.hide();
|
||||
}
|
||||
$icon.css({
|
||||
'cursor': ''
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a tooltip or popover
|
||||
*
|
||||
* @param {jQuery} $field The field element
|
||||
* @param {String} type Can be 'tooltip' or 'popover'
|
||||
*/
|
||||
_showTooltip: function($field, type) {
|
||||
var $icon = $field.data('fv.icon');
|
||||
if ($icon) {
|
||||
$icon.css({
|
||||
'cursor': 'pointer'
|
||||
});
|
||||
var tooltip = $icon.data('tooltip');
|
||||
if (tooltip) {
|
||||
tooltip.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return FormValidation.Framework.UIKit;
|
||||
}));
|
||||
@@ -1,181 +0,0 @@
|
||||
/**
|
||||
* FormValidation (http://formvalidation.io)
|
||||
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit frameworks
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("helper", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
|
||||
// Helper methods, which can be used in validator class
|
||||
FormValidation.Helper = {
|
||||
/**
|
||||
* Execute a callback function
|
||||
*
|
||||
* @param {String|Function} functionName Can be
|
||||
* - name of global function
|
||||
* - name of namespace function (such as A.B.C)
|
||||
* - a function
|
||||
* @param {Array} args The callback arguments
|
||||
*/
|
||||
call: function(functionName, args) {
|
||||
if ('function' === typeof functionName) {
|
||||
return functionName.apply(this, args);
|
||||
} else if ('string' === typeof functionName) {
|
||||
if ('()' === functionName.substring(functionName.length - 2)) {
|
||||
functionName = functionName.substring(0, functionName.length - 2);
|
||||
}
|
||||
var ns = functionName.split('.'),
|
||||
func = ns.pop(),
|
||||
context = window;
|
||||
for (var i = 0; i < ns.length; i++) {
|
||||
context = context[ns[i]];
|
||||
}
|
||||
|
||||
return (typeof context[func] === 'undefined') ? null : context[func].apply(this, args);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate a date
|
||||
*
|
||||
* @param {Number} year The full year in 4 digits
|
||||
* @param {Number} month The month number
|
||||
* @param {Number} day The day number
|
||||
* @param {Boolean} [notInFuture] If true, the date must not be in the future
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
date: function(year, month, day, notInFuture) {
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
||||
return false;
|
||||
}
|
||||
if (day.length > 2 || month.length > 2 || year.length > 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
day = parseInt(day, 10);
|
||||
month = parseInt(month, 10);
|
||||
year = parseInt(year, 10);
|
||||
|
||||
if (year < 1000 || year > 9999 || month <= 0 || month > 12) {
|
||||
return false;
|
||||
}
|
||||
var numDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
// Update the number of days in Feb of leap year
|
||||
if (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)) {
|
||||
numDays[1] = 29;
|
||||
}
|
||||
|
||||
// Check the day
|
||||
if (day <= 0 || day > numDays[month - 1]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (notInFuture === true) {
|
||||
var currentDate = new Date(),
|
||||
currentYear = currentDate.getFullYear(),
|
||||
currentMonth = currentDate.getMonth(),
|
||||
currentDay = currentDate.getDate();
|
||||
return (year < currentYear
|
||||
|| (year === currentYear && month - 1 < currentMonth)
|
||||
|| (year === currentYear && month - 1 === currentMonth && day < currentDay));
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Format a string
|
||||
* It's used to format the error message
|
||||
* format('The field must between %s and %s', [10, 20]) = 'The field must between 10 and 20'
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Array} parameters
|
||||
* @returns {String}
|
||||
*/
|
||||
format: function(message, parameters) {
|
||||
if (!$.isArray(parameters)) {
|
||||
parameters = [parameters];
|
||||
}
|
||||
|
||||
for (var i in parameters) {
|
||||
message = message.replace('%s', parameters[i]);
|
||||
}
|
||||
|
||||
return message;
|
||||
},
|
||||
|
||||
/**
|
||||
* Implement Luhn validation algorithm
|
||||
* Credit to https://gist.github.com/ShirtlessKirk/2134376
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Luhn
|
||||
* @param {String} value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
luhn: function(value) {
|
||||
var length = value.length,
|
||||
mul = 0,
|
||||
prodArr = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]],
|
||||
sum = 0;
|
||||
|
||||
while (length--) {
|
||||
sum += prodArr[mul][parseInt(value.charAt(length), 10)];
|
||||
mul ^= 1;
|
||||
}
|
||||
|
||||
return (sum % 10 === 0 && sum > 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Implement modulus 11, 10 (ISO 7064) algorithm
|
||||
*
|
||||
* @param {String} value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
mod11And10: function(value) {
|
||||
var check = 5,
|
||||
length = value.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
check = (((check || 10) * 2) % 11 + parseInt(value.charAt(i), 10)) % 10;
|
||||
}
|
||||
return (check === 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Implements Mod 37, 36 (ISO 7064) algorithm
|
||||
* Usages:
|
||||
* mod37And36('A12425GABC1234002M')
|
||||
* mod37And36('002006673085', '0123456789')
|
||||
*
|
||||
* @param {String} value
|
||||
* @param {String} [alphabet]
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
mod37And36: function(value, alphabet) {
|
||||
alphabet = alphabet || '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
var modulus = alphabet.length,
|
||||
length = value.length,
|
||||
check = Math.floor(modulus / 2);
|
||||
for (var i = 0; i < length; i++) {
|
||||
check = (((check || modulus) * 2) % (modulus + 1) + alphabet.indexOf(value.charAt(i))) % modulus;
|
||||
}
|
||||
return (check === 1);
|
||||
}
|
||||
};
|
||||
return FormValidation.Helper;
|
||||
}));
|
||||
@@ -1,391 +0,0 @@
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("language/zh_CN", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
/**
|
||||
* Simplified Chinese language package
|
||||
* Translated by @shamiao
|
||||
*/
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n, {
|
||||
'zh_CN': {
|
||||
base64: {
|
||||
'default': '请输入有效的Base64编码'
|
||||
},
|
||||
between: {
|
||||
'default': '请输入在 %s 和 %s 之间的数值',
|
||||
notInclusive: '请输入在 %s 和 %s 之间(不含两端)的数值'
|
||||
},
|
||||
bic: {
|
||||
'default': '请输入有效的BIC商品编码'
|
||||
},
|
||||
callback: {
|
||||
'default': '请输入有效的值'
|
||||
},
|
||||
choice: {
|
||||
'default': '请输入有效的值',
|
||||
less: '请至少选中 %s 个选项',
|
||||
more: '最多只能选中 %s 个选项',
|
||||
between: '请选择 %s 至 %s 个选项'
|
||||
},
|
||||
color: {
|
||||
'default': '请输入有效的颜色值'
|
||||
},
|
||||
creditCard: {
|
||||
'default': '请输入有效的信用卡号码'
|
||||
},
|
||||
cusip: {
|
||||
'default': '请输入有效的美国CUSIP代码'
|
||||
},
|
||||
cvv: {
|
||||
'default': '请输入有效的CVV代码'
|
||||
},
|
||||
date: {
|
||||
'default': '请输入有效的日期',
|
||||
min: '请输入 %s 或之后的日期',
|
||||
max: '请输入 %s 或以前的日期',
|
||||
range: '请输入 %s 和 %s 之间的日期'
|
||||
},
|
||||
different: {
|
||||
'default': '请输入不同的值'
|
||||
},
|
||||
digits: {
|
||||
'default': '请输入有效的数字'
|
||||
},
|
||||
ean: {
|
||||
'default': '请输入有效的EAN商品编码'
|
||||
},
|
||||
ein: {
|
||||
'default': '请输入有效的EIN商品编码'
|
||||
},
|
||||
emailAddress: {
|
||||
'default': '请输入有效的邮件地址'
|
||||
},
|
||||
file: {
|
||||
'default': '请选择有效的文件'
|
||||
},
|
||||
greaterThan: {
|
||||
'default': '请输入大于等于 %s 的数值',
|
||||
notInclusive: '请输入大于 %s 的数值'
|
||||
},
|
||||
grid: {
|
||||
'default': '请输入有效的GRId编码'
|
||||
},
|
||||
hex: {
|
||||
'default': '请输入有效的16进制数'
|
||||
},
|
||||
iban: {
|
||||
'default': '请输入有效的IBAN(国际银行账户)号码',
|
||||
country: '请输入有效的 %s 国家或地区的IBAN(国际银行账户)号码',
|
||||
countries: {
|
||||
AD: '安道尔',
|
||||
AE: '阿联酋',
|
||||
AL: '阿尔巴尼亚',
|
||||
AO: '安哥拉',
|
||||
AT: '奥地利',
|
||||
AZ: '阿塞拜疆',
|
||||
BA: '波斯尼亚和黑塞哥维那',
|
||||
BE: '比利时',
|
||||
BF: '布基纳法索',
|
||||
BG: '保加利亚',
|
||||
BH: '巴林',
|
||||
BI: '布隆迪',
|
||||
BJ: '贝宁',
|
||||
BR: '巴西',
|
||||
CH: '瑞士',
|
||||
CI: '科特迪瓦',
|
||||
CM: '喀麦隆',
|
||||
CR: '哥斯达黎加',
|
||||
CV: '佛得角',
|
||||
CY: '塞浦路斯',
|
||||
CZ: '捷克共和国',
|
||||
DE: '德国',
|
||||
DK: '丹麦',
|
||||
DO: '多米尼加共和国',
|
||||
DZ: '阿尔及利亚',
|
||||
EE: '爱沙尼亚',
|
||||
ES: '西班牙',
|
||||
FI: '芬兰',
|
||||
FO: '法罗群岛',
|
||||
FR: '法国',
|
||||
GB: '英国',
|
||||
GE: '格鲁吉亚',
|
||||
GI: '直布罗陀',
|
||||
GL: '格陵兰岛',
|
||||
GR: '希腊',
|
||||
GT: '危地马拉',
|
||||
HR: '克罗地亚',
|
||||
HU: '匈牙利',
|
||||
IE: '爱尔兰',
|
||||
IL: '以色列',
|
||||
IR: '伊朗',
|
||||
IS: '冰岛',
|
||||
IT: '意大利',
|
||||
JO: '约旦',
|
||||
KW: '科威特',
|
||||
KZ: '哈萨克斯坦',
|
||||
LB: '黎巴嫩',
|
||||
LI: '列支敦士登',
|
||||
LT: '立陶宛',
|
||||
LU: '卢森堡',
|
||||
LV: '拉脱维亚',
|
||||
MC: '摩纳哥',
|
||||
MD: '摩尔多瓦',
|
||||
ME: '黑山',
|
||||
MG: '马达加斯加',
|
||||
MK: '马其顿',
|
||||
ML: '马里',
|
||||
MR: '毛里塔尼亚',
|
||||
MT: '马耳他',
|
||||
MU: '毛里求斯',
|
||||
MZ: '莫桑比克',
|
||||
NL: '荷兰',
|
||||
NO: '挪威',
|
||||
PK: '巴基斯坦',
|
||||
PL: '波兰',
|
||||
PS: '巴勒斯坦',
|
||||
PT: '葡萄牙',
|
||||
QA: '卡塔尔',
|
||||
RO: '罗马尼亚',
|
||||
RS: '塞尔维亚',
|
||||
SA: '沙特阿拉伯',
|
||||
SE: '瑞典',
|
||||
SI: '斯洛文尼亚',
|
||||
SK: '斯洛伐克',
|
||||
SM: '圣马力诺',
|
||||
SN: '塞内加尔',
|
||||
TN: '突尼斯',
|
||||
TR: '土耳其',
|
||||
VG: '英属维尔京群岛'
|
||||
}
|
||||
},
|
||||
id: {
|
||||
'default': '请输入有效的身份证件号码',
|
||||
country: '请输入有效的 %s 国家或地区的身份证件号码',
|
||||
countries: {
|
||||
BA: '波黑',
|
||||
BG: '保加利亚',
|
||||
BR: '巴西',
|
||||
CH: '瑞士',
|
||||
CL: '智利',
|
||||
CN: '中国',
|
||||
CZ: '捷克共和国',
|
||||
DK: '丹麦',
|
||||
EE: '爱沙尼亚',
|
||||
ES: '西班牙',
|
||||
FI: '芬兰',
|
||||
HR: '克罗地亚',
|
||||
IE: '爱尔兰',
|
||||
IS: '冰岛',
|
||||
LT: '立陶宛',
|
||||
LV: '拉脱维亚',
|
||||
ME: '黑山',
|
||||
MK: '马其顿',
|
||||
NL: '荷兰',
|
||||
RO: '罗马尼亚',
|
||||
RS: '塞尔维亚',
|
||||
SE: '瑞典',
|
||||
SI: '斯洛文尼亚',
|
||||
SK: '斯洛伐克',
|
||||
SM: '圣马力诺',
|
||||
TH: '泰国',
|
||||
ZA: '南非'
|
||||
}
|
||||
},
|
||||
identical: {
|
||||
'default': '请输入相同的值'
|
||||
},
|
||||
imei: {
|
||||
'default': '请输入有效的IMEI(手机串号)'
|
||||
},
|
||||
imo: {
|
||||
'default': '请输入有效的国际海事组织(IMO)号码'
|
||||
},
|
||||
integer: {
|
||||
'default': '请输入有效的整数值'
|
||||
},
|
||||
ip: {
|
||||
'default': '请输入有效的IP地址',
|
||||
ipv4: '请输入有效的IPv4地址',
|
||||
ipv6: '请输入有效的IPv6地址'
|
||||
},
|
||||
isbn: {
|
||||
'default': '请输入有效的ISBN(国际标准书号)'
|
||||
},
|
||||
isin: {
|
||||
'default': '请输入有效的ISIN(国际证券编码)'
|
||||
},
|
||||
ismn: {
|
||||
'default': '请输入有效的ISMN(印刷音乐作品编码)'
|
||||
},
|
||||
issn: {
|
||||
'default': '请输入有效的ISSN(国际标准杂志书号)'
|
||||
},
|
||||
lessThan: {
|
||||
'default': '请输入小于等于 %s 的数值',
|
||||
notInclusive: '请输入小于 %s 的数值'
|
||||
},
|
||||
mac: {
|
||||
'default': '请输入有效的MAC物理地址'
|
||||
},
|
||||
meid: {
|
||||
'default': '请输入有效的MEID(移动设备识别码)'
|
||||
},
|
||||
notEmpty: {
|
||||
'default': '请填写必填项目'
|
||||
},
|
||||
numeric: {
|
||||
'default': '请输入有效的数值,允许小数'
|
||||
},
|
||||
phone: {
|
||||
'default': '请输入有效的电话号码',
|
||||
country: '请输入有效的 %s 国家或地区的电话号码',
|
||||
countries: {
|
||||
AE: '阿联酋',
|
||||
BG: '保加利亚',
|
||||
BR: '巴西',
|
||||
CN: '中国',
|
||||
CZ: '捷克共和国',
|
||||
DE: '德国',
|
||||
DK: '丹麦',
|
||||
ES: '西班牙',
|
||||
FR: '法国',
|
||||
GB: '英国',
|
||||
IN: '印度',
|
||||
MA: '摩洛哥',
|
||||
NL: '荷兰',
|
||||
PK: '巴基斯坦',
|
||||
RO: '罗马尼亚',
|
||||
RU: '俄罗斯',
|
||||
SK: '斯洛伐克',
|
||||
TH: '泰国',
|
||||
US: '美国',
|
||||
VE: '委内瑞拉'
|
||||
}
|
||||
},
|
||||
regexp: {
|
||||
'default': '请输入符合正则表达式限制的值'
|
||||
},
|
||||
remote: {
|
||||
'default': '请输入有效的值'
|
||||
},
|
||||
rtn: {
|
||||
'default': '请输入有效的RTN号码'
|
||||
},
|
||||
sedol: {
|
||||
'default': '请输入有效的SEDOL代码'
|
||||
},
|
||||
siren: {
|
||||
'default': '请输入有效的SIREN号码'
|
||||
},
|
||||
siret: {
|
||||
'default': '请输入有效的SIRET号码'
|
||||
},
|
||||
step: {
|
||||
'default': '请输入在基础值上,增加 %s 的整数倍的数值'
|
||||
},
|
||||
stringCase: {
|
||||
'default': '只能输入小写字母',
|
||||
upper: '只能输入大写字母'
|
||||
},
|
||||
stringLength: {
|
||||
'default': '请输入符合长度限制的值',
|
||||
less: '最多只能输入 %s 个字符',
|
||||
more: '需要输入至少 %s 个字符',
|
||||
between: '请输入 %s 至 %s 个字符'
|
||||
},
|
||||
uri: {
|
||||
'default': '请输入一个有效的URL地址'
|
||||
},
|
||||
uuid: {
|
||||
'default': '请输入有效的UUID',
|
||||
version: '请输入版本 %s 的UUID'
|
||||
},
|
||||
vat: {
|
||||
'default': '请输入有效的VAT(税号)',
|
||||
country: '请输入有效的 %s 国家或地区的VAT(税号)',
|
||||
countries: {
|
||||
AT: '奥地利',
|
||||
BE: '比利时',
|
||||
BG: '保加利亚',
|
||||
BR: '巴西',
|
||||
CH: '瑞士',
|
||||
CY: '塞浦路斯',
|
||||
CZ: '捷克共和国',
|
||||
DE: '德国',
|
||||
DK: '丹麦',
|
||||
EE: '爱沙尼亚',
|
||||
ES: '西班牙',
|
||||
FI: '芬兰',
|
||||
FR: '法语',
|
||||
GB: '英国',
|
||||
GR: '希腊',
|
||||
EL: '希腊',
|
||||
HU: '匈牙利',
|
||||
HR: '克罗地亚',
|
||||
IE: '爱尔兰',
|
||||
IS: '冰岛',
|
||||
IT: '意大利',
|
||||
LT: '立陶宛',
|
||||
LU: '卢森堡',
|
||||
LV: '拉脱维亚',
|
||||
MT: '马耳他',
|
||||
NL: '荷兰',
|
||||
NO: '挪威',
|
||||
PL: '波兰',
|
||||
PT: '葡萄牙',
|
||||
RO: '罗马尼亚',
|
||||
RU: '俄罗斯',
|
||||
RS: '塞尔维亚',
|
||||
SE: '瑞典',
|
||||
SI: '斯洛文尼亚',
|
||||
SK: '斯洛伐克',
|
||||
VE: '委内瑞拉',
|
||||
ZA: '南非'
|
||||
}
|
||||
},
|
||||
vin: {
|
||||
'default': '请输入有效的VIN(美国车辆识别号码)'
|
||||
},
|
||||
zipCode: {
|
||||
'default': '请输入有效的邮政编码',
|
||||
country: '请输入有效的 %s 国家或地区的邮政编码',
|
||||
countries: {
|
||||
AT: '奥地利',
|
||||
BG: '保加利亚',
|
||||
BR: '巴西',
|
||||
CA: '加拿大',
|
||||
CH: '瑞士',
|
||||
CZ: '捷克共和国',
|
||||
DE: '德国',
|
||||
DK: '丹麦',
|
||||
ES: '西班牙',
|
||||
FR: '法国',
|
||||
GB: '英国',
|
||||
IE: '爱尔兰',
|
||||
IN: '印度',
|
||||
IT: '意大利',
|
||||
MA: '摩洛哥',
|
||||
NL: '荷兰',
|
||||
PT: '葡萄牙',
|
||||
RO: '罗马尼亚',
|
||||
RU: '俄罗斯',
|
||||
SE: '瑞典',
|
||||
SG: '新加坡',
|
||||
SK: '斯洛伐克',
|
||||
US: '美国'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return FormValidation.I18n.zh_CN;
|
||||
}));
|
||||
@@ -1,391 +0,0 @@
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("language/zh_TW", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
/**
|
||||
* Traditional Chinese language package
|
||||
* Translated by @tureki
|
||||
*/
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n, {
|
||||
'zh_TW': {
|
||||
base64: {
|
||||
'default': '請輸入有效的Base64編碼'
|
||||
},
|
||||
between: {
|
||||
'default': '請輸入不小於 %s 且不大於 %s 的值',
|
||||
notInclusive: '請輸入不小於等於 %s 且不大於等於 %s 的值'
|
||||
},
|
||||
bic: {
|
||||
'default': '請輸入有效的BIC商品編碼'
|
||||
},
|
||||
callback: {
|
||||
'default': '請輸入有效的值'
|
||||
},
|
||||
choice: {
|
||||
'default': '請輸入有效的值',
|
||||
less: '最少選擇 %s 個選項',
|
||||
more: '最多選擇 %s 個選項',
|
||||
between: '請選擇 %s 至 %s 個選項'
|
||||
},
|
||||
color: {
|
||||
'default': '請輸入有效的元色碼'
|
||||
},
|
||||
creditCard: {
|
||||
'default': '請輸入有效的信用卡號碼'
|
||||
},
|
||||
cusip: {
|
||||
'default': '請輸入有效的CUSIP(美國證券庫斯普)號碼'
|
||||
},
|
||||
cvv: {
|
||||
'default': '請輸入有效的CVV(信用卡檢查碼)代碼'
|
||||
},
|
||||
date: {
|
||||
'default': '請輸入有效的日期',
|
||||
min: '請輸入 %s 或之後的日期',
|
||||
max: '請輸入 %s 或以前的日期',
|
||||
range: '請輸入 %s 至 %s 之間的日期'
|
||||
},
|
||||
different: {
|
||||
'default': '請輸入不同的值'
|
||||
},
|
||||
digits: {
|
||||
'default': '只能輸入數字'
|
||||
},
|
||||
ean: {
|
||||
'default': '請輸入有效的EAN商品編碼'
|
||||
},
|
||||
ein: {
|
||||
'default': '請輸入有效的EIN商品編碼'
|
||||
},
|
||||
emailAddress: {
|
||||
'default': '請輸入有效的EMAIL'
|
||||
},
|
||||
file: {
|
||||
'default': '請選擇有效的檔案'
|
||||
},
|
||||
greaterThan: {
|
||||
'default': '請輸入大於等於 %s 的值',
|
||||
notInclusive: '請輸入大於 %s 的值'
|
||||
},
|
||||
grid: {
|
||||
'default': '請輸入有效的GRId編碼'
|
||||
},
|
||||
hex: {
|
||||
'default': '請輸入有效的16位元碼'
|
||||
},
|
||||
iban: {
|
||||
'default': '請輸入有效的IBAN(國際銀行賬戶)號碼',
|
||||
country: '請輸入有效的 %s 國家的IBAN(國際銀行賬戶)號碼',
|
||||
countries: {
|
||||
AD: '安道爾',
|
||||
AE: '阿聯酋',
|
||||
AL: '阿爾巴尼亞',
|
||||
AO: '安哥拉',
|
||||
AT: '奧地利',
|
||||
AZ: '阿塞拜疆',
|
||||
BA: '波斯尼亞和黑塞哥維那',
|
||||
BE: '比利時',
|
||||
BF: '布基納法索',
|
||||
BG: '保加利亞',
|
||||
BH: '巴林',
|
||||
BI: '布隆迪',
|
||||
BJ: '貝寧',
|
||||
BR: '巴西',
|
||||
CH: '瑞士',
|
||||
CI: '象牙海岸',
|
||||
CM: '喀麥隆',
|
||||
CR: '哥斯達黎加',
|
||||
CV: '佛得角',
|
||||
CY: '塞浦路斯',
|
||||
CZ: '捷克共和國',
|
||||
DE: '德國',
|
||||
DK: '丹麥',
|
||||
DO: '多明尼加共和國',
|
||||
DZ: '阿爾及利亞',
|
||||
EE: '愛沙尼亞',
|
||||
ES: '西班牙',
|
||||
FI: '芬蘭',
|
||||
FO: '法羅群島',
|
||||
FR: '法國',
|
||||
GB: '英國',
|
||||
GE: '格魯吉亞',
|
||||
GI: '直布羅陀',
|
||||
GL: '格陵蘭島',
|
||||
GR: '希臘',
|
||||
GT: '危地馬拉',
|
||||
HR: '克羅地亞',
|
||||
HU: '匈牙利',
|
||||
IE: '愛爾蘭',
|
||||
IL: '以色列',
|
||||
IR: '伊朗',
|
||||
IS: '冰島',
|
||||
IT: '意大利',
|
||||
JO: '約旦',
|
||||
KW: '科威特',
|
||||
KZ: '哈薩克斯坦',
|
||||
LB: '黎巴嫩',
|
||||
LI: '列支敦士登',
|
||||
LT: '立陶宛',
|
||||
LU: '盧森堡',
|
||||
LV: '拉脫維亞',
|
||||
MC: '摩納哥',
|
||||
MD: '摩爾多瓦',
|
||||
ME: '蒙特內哥羅',
|
||||
MG: '馬達加斯加',
|
||||
MK: '馬其頓',
|
||||
ML: '馬里',
|
||||
MR: '毛里塔尼亞',
|
||||
MT: '馬耳他',
|
||||
MU: '毛里求斯',
|
||||
MZ: '莫桑比克',
|
||||
NL: '荷蘭',
|
||||
NO: '挪威',
|
||||
PK: '巴基斯坦',
|
||||
PL: '波蘭',
|
||||
PS: '巴勒斯坦',
|
||||
PT: '葡萄牙',
|
||||
QA: '卡塔爾',
|
||||
RO: '羅馬尼亞',
|
||||
RS: '塞爾維亞',
|
||||
SA: '沙特阿拉伯',
|
||||
SE: '瑞典',
|
||||
SI: '斯洛文尼亞',
|
||||
SK: '斯洛伐克',
|
||||
SM: '聖馬力諾',
|
||||
SN: '塞內加爾',
|
||||
TN: '突尼斯',
|
||||
TR: '土耳其',
|
||||
VG: '英屬維爾京群島'
|
||||
}
|
||||
},
|
||||
id: {
|
||||
'default': '請輸入有效的身份證字號',
|
||||
country: '請輸入有效的 %s 身份證字號',
|
||||
countries: {
|
||||
BA: '波赫',
|
||||
BG: '保加利亞',
|
||||
BR: '巴西',
|
||||
CH: '瑞士',
|
||||
CL: '智利',
|
||||
CN: '中國',
|
||||
CZ: '捷克共和國',
|
||||
DK: '丹麥',
|
||||
EE: '愛沙尼亞',
|
||||
ES: '西班牙',
|
||||
FI: '芬蘭',
|
||||
HR: '克羅地亞',
|
||||
IE: '愛爾蘭',
|
||||
IS: '冰島',
|
||||
LT: '立陶宛',
|
||||
LV: '拉脫維亞',
|
||||
ME: '蒙特內哥羅',
|
||||
MK: '馬其頓',
|
||||
NL: '荷蘭',
|
||||
RO: '羅馬尼亞',
|
||||
RS: '塞爾維亞',
|
||||
SE: '瑞典',
|
||||
SI: '斯洛文尼亞',
|
||||
SK: '斯洛伐克',
|
||||
SM: '聖馬力諾',
|
||||
TH: '泰國',
|
||||
ZA: '南非'
|
||||
}
|
||||
},
|
||||
identical: {
|
||||
'default': '請輸入相同的值'
|
||||
},
|
||||
imei: {
|
||||
'default': '請輸入有效的IMEI(手機序列號)'
|
||||
},
|
||||
imo: {
|
||||
'default': '請輸入有效的國際海事組織(IMO)號碼'
|
||||
},
|
||||
integer: {
|
||||
'default': '請輸入有效的整數'
|
||||
},
|
||||
ip: {
|
||||
'default': '請輸入有效的IP位址',
|
||||
ipv4: '請輸入有效的IPv4位址',
|
||||
ipv6: '請輸入有效的IPv6位址'
|
||||
},
|
||||
isbn: {
|
||||
'default': '請輸入有效的ISBN(國際標準書號)'
|
||||
},
|
||||
isin: {
|
||||
'default': '請輸入有效的ISIN(國際證券號碼)'
|
||||
},
|
||||
ismn: {
|
||||
'default': '請輸入有效的ISMN(國際標準音樂編號)'
|
||||
},
|
||||
issn: {
|
||||
'default': '請輸入有效的ISSN(國際標準期刊號)'
|
||||
},
|
||||
lessThan: {
|
||||
'default': '請輸入小於等於 %s 的值',
|
||||
notInclusive: '請輸入小於 %s 的值'
|
||||
},
|
||||
mac: {
|
||||
'default': '請輸入有效的MAC位址'
|
||||
},
|
||||
meid: {
|
||||
'default': '請輸入有效的MEID(行動設備識別碼)'
|
||||
},
|
||||
notEmpty: {
|
||||
'default': '請填寫必填欄位'
|
||||
},
|
||||
numeric: {
|
||||
'default': '請輸入有效的數字(含浮點數)'
|
||||
},
|
||||
phone: {
|
||||
'default': '請輸入有效的電話號碼',
|
||||
country: '請輸入有效的 %s 國家的電話號碼',
|
||||
countries: {
|
||||
AE: '阿聯酋',
|
||||
BG: '保加利亞',
|
||||
BR: '巴西',
|
||||
CN: '中国',
|
||||
CZ: '捷克共和國',
|
||||
DE: '德國',
|
||||
DK: '丹麥',
|
||||
ES: '西班牙',
|
||||
FR: '法國',
|
||||
GB: '英國',
|
||||
IN: '印度',
|
||||
MA: '摩洛哥',
|
||||
NL: '荷蘭',
|
||||
PK: '巴基斯坦',
|
||||
RO: '罗马尼亚',
|
||||
RU: '俄羅斯',
|
||||
SK: '斯洛伐克',
|
||||
TH: '泰國',
|
||||
US: '美國',
|
||||
VE: '委内瑞拉'
|
||||
}
|
||||
},
|
||||
regexp: {
|
||||
'default': '請輸入符合正規表示式所限制的值'
|
||||
},
|
||||
remote: {
|
||||
'default': '請輸入有效的值'
|
||||
},
|
||||
rtn: {
|
||||
'default': '請輸入有效的RTN號碼'
|
||||
},
|
||||
sedol: {
|
||||
'default': '請輸入有效的SEDOL代碼'
|
||||
},
|
||||
siren: {
|
||||
'default': '請輸入有效的SIREN號碼'
|
||||
},
|
||||
siret: {
|
||||
'default': '請輸入有效的SIRET號碼'
|
||||
},
|
||||
step: {
|
||||
'default': '請輸入 %s 的倍數'
|
||||
},
|
||||
stringCase: {
|
||||
'default': '只能輸入小寫字母',
|
||||
upper: '只能輸入大寫字母'
|
||||
},
|
||||
stringLength: {
|
||||
'default': '請輸入符合長度限制的值',
|
||||
less: '請輸入小於 %s 個字',
|
||||
more: '請輸入大於 %s 個字',
|
||||
between: '請輸入 %s 至 %s 個字'
|
||||
},
|
||||
uri: {
|
||||
'default': '請輸入一個有效的鏈接'
|
||||
},
|
||||
uuid: {
|
||||
'default': '請輸入有效的UUID',
|
||||
version: '請輸入版本 %s 的UUID'
|
||||
},
|
||||
vat: {
|
||||
'default': '請輸入有效的VAT(增值税)',
|
||||
country: '請輸入有效的 %s 國家的VAT(增值税)',
|
||||
countries: {
|
||||
AT: '奧地利',
|
||||
BE: '比利時',
|
||||
BG: '保加利亞',
|
||||
BR: '巴西',
|
||||
CH: '瑞士',
|
||||
CY: '塞浦路斯',
|
||||
CZ: '捷克共和國',
|
||||
DE: '德國',
|
||||
DK: '丹麥',
|
||||
EE: '愛沙尼亞',
|
||||
ES: '西班牙',
|
||||
FI: '芬蘭',
|
||||
FR: '法語',
|
||||
GB: '英國',
|
||||
GR: '希臘',
|
||||
EL: '希臘',
|
||||
HU: '匈牙利',
|
||||
HR: '克羅地亞',
|
||||
IE: '愛爾蘭',
|
||||
IS: '冰島',
|
||||
IT: '意大利',
|
||||
LT: '立陶宛',
|
||||
LU: '盧森堡',
|
||||
LV: '拉脫維亞',
|
||||
MT: '馬耳他',
|
||||
NL: '荷蘭',
|
||||
NO: '挪威',
|
||||
PL: '波蘭',
|
||||
PT: '葡萄牙',
|
||||
RO: '羅馬尼亞',
|
||||
RU: '俄羅斯',
|
||||
RS: '塞爾維亞',
|
||||
SE: '瑞典',
|
||||
SI: '斯洛文尼亞',
|
||||
SK: '斯洛伐克',
|
||||
VE: '委内瑞拉',
|
||||
ZA: '南非'
|
||||
}
|
||||
},
|
||||
vin: {
|
||||
'default': '請輸入有效的VIN(車輛識別號碼)'
|
||||
},
|
||||
zipCode: {
|
||||
'default': '請輸入有效的郵政編碼',
|
||||
country: '請輸入有效的 %s 國家的郵政編碼',
|
||||
countries: {
|
||||
AT: '奧地利',
|
||||
BG: '保加利亞',
|
||||
BR: '巴西',
|
||||
CA: '加拿大',
|
||||
CH: '瑞士',
|
||||
CZ: '捷克共和國',
|
||||
DE: '德國',
|
||||
DK: '丹麥',
|
||||
ES: '西班牙',
|
||||
FR: '法國',
|
||||
GB: '英國',
|
||||
IE: '愛爾蘭',
|
||||
IN: '印度',
|
||||
IT: '意大利',
|
||||
MA: '摩洛哥',
|
||||
NL: '荷蘭',
|
||||
PT: '葡萄牙',
|
||||
RO: '羅馬尼亞',
|
||||
RU: '俄羅斯',
|
||||
SE: '瑞典',
|
||||
SG: '新加坡',
|
||||
SK: '斯洛伐克',
|
||||
US: '美國'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return FormValidation.I18n.zh_TW;
|
||||
}));
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* base64 validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/base64/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/XXXXXXXXXXXXXXXXXXXXXXXXXbase64", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
base64: {
|
||||
'default': 'Please enter a valid base 64 encoded'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.base64 = {
|
||||
/**
|
||||
* Return true if the input value is a base 64 encoded string.
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'base64');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
return FormValidation.Validator.base64;
|
||||
}));
|
||||
@@ -1,105 +0,0 @@
|
||||
/**
|
||||
* between validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/between/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/between", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
between: {
|
||||
'default': 'Please enter a value between %s and %s',
|
||||
notInclusive: 'Please enter a value between %s and %s strictly'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.between = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
min: 'min',
|
||||
max: 'max',
|
||||
inclusive: 'inclusive'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
if ('range' === $field.attr('type')) {
|
||||
return {
|
||||
min: $field.attr('min'),
|
||||
max: $field.attr('max')
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is between (strictly or not) two given numbers
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - min
|
||||
* - max
|
||||
*
|
||||
* The min, max keys define the number which the field value compares to. min, max can be
|
||||
* - A number
|
||||
* - Name of field which its value defines the number
|
||||
* - Name of callback function that returns the number
|
||||
* - A callback function that returns the number
|
||||
*
|
||||
* - inclusive [optional]: Can be true or false. Default is true
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'between');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = this._format(value);
|
||||
if (!$.isNumeric(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
|
||||
max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
|
||||
minValue = this._format(min),
|
||||
maxValue = this._format(max);
|
||||
|
||||
value = parseFloat(value);
|
||||
return (options.inclusive === true || options.inclusive === undefined)
|
||||
? {
|
||||
valid: value >= minValue && value <= maxValue,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].between['default'], [min, max])
|
||||
}
|
||||
: {
|
||||
valid: value > minValue && value < maxValue,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].between.notInclusive, [min, max])
|
||||
};
|
||||
},
|
||||
|
||||
_format: function(value) {
|
||||
return (value + '').replace(',', '.');
|
||||
}
|
||||
};
|
||||
|
||||
return FormValidation.Validator.between;
|
||||
}));
|
||||
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* bic validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/bic/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/bic", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
bic: {
|
||||
'default': 'Please enter a valid BIC number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.bic = {
|
||||
/**
|
||||
* Validate an Business Identifier Code (BIC), also known as ISO 9362, SWIFT-BIC, SWIFT ID or SWIFT code
|
||||
*
|
||||
* For more information see http://en.wikipedia.org/wiki/ISO_9362
|
||||
*
|
||||
* @todo The 5 and 6 characters are an ISO 3166-1 country code, this could also be validated
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'bic');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
return /^[a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?$/.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.bic;
|
||||
}));
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* blank validator
|
||||
*
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/blank", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.Validator.blank = {
|
||||
/**
|
||||
* Placeholder validator that can be used to display a custom validation message
|
||||
* returned from the server
|
||||
* Example:
|
||||
*
|
||||
* (1) a "blank" validator is applied to an input field.
|
||||
* (2) data is entered via the UI that is unable to be validated client-side.
|
||||
* (3) server returns a 400 with JSON data that contains the field that failed
|
||||
* validation and an associated message.
|
||||
* (4) ajax 400 call handler does the following:
|
||||
*
|
||||
* bv.updateMessage(field, 'blank', errorMessage);
|
||||
* bv.updateStatus(field, 'INVALID');
|
||||
*
|
||||
* @see https://github.com/formvalidation/formvalidation/issues/542
|
||||
* @see https://github.com/formvalidation/formvalidation/pull/666
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.blank;
|
||||
}));
|
||||
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* callback validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/callback/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/callback", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
callback: {
|
||||
'default': 'Please enter a valid value'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.callback = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
callback: 'callback'
|
||||
},
|
||||
|
||||
/**
|
||||
* Return result from the callback method
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - callback: The callback method that passes 2 parameters:
|
||||
* callback: function(fieldValue, validator, $field) {
|
||||
* // fieldValue is the value of field
|
||||
* // validator is instance of BootstrapValidator
|
||||
* // $field is the field element
|
||||
* }
|
||||
* - message: The invalid message
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'callback'),
|
||||
dfd = new $.Deferred(),
|
||||
result = { valid: true };
|
||||
|
||||
if (options.callback) {
|
||||
var response = FormValidation.Helper.call(options.callback, [value, validator, $field]);
|
||||
result = ('boolean' === typeof response) ? { valid: response } : response;
|
||||
}
|
||||
|
||||
dfd.resolve($field, 'callback', result);
|
||||
return dfd;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.callback;
|
||||
}));
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* choice validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/choice/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/choice", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
choice: {
|
||||
'default': 'Please enter a valid value',
|
||||
less: 'Please choose %s options at minimum',
|
||||
more: 'Please choose %s options at maximum',
|
||||
between: 'Please choose %s - %s options'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.choice = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
min: 'min',
|
||||
max: 'max'
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the number of checked boxes are less or more than a given number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of following keys:
|
||||
* - min
|
||||
* - max
|
||||
*
|
||||
* At least one of two keys is required
|
||||
* The min, max keys define the number which the field value compares to. min, max can be
|
||||
* - A number
|
||||
* - Name of field which its value defines the number
|
||||
* - Name of callback function that returns the number
|
||||
* - A callback function that returns the number
|
||||
*
|
||||
* - message: The invalid message
|
||||
* @returns {Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var locale = validator.getLocale(),
|
||||
ns = validator.getNamespace(),
|
||||
numChoices = $field.is('select')
|
||||
? validator.getFieldElements($field.attr('data-' + ns + '-field')).find('option').filter(':selected').length
|
||||
: validator.getFieldElements($field.attr('data-' + ns + '-field')).filter(':checked').length,
|
||||
min = options.min ? ($.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min)) : null,
|
||||
max = options.max ? ($.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max)) : null,
|
||||
isValid = true,
|
||||
message = options.message || FormValidation.I18n[locale].choice['default'];
|
||||
|
||||
if ((min && numChoices < parseInt(min, 10)) || (max && numChoices > parseInt(max, 10))) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case (!!min && !!max):
|
||||
message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].choice.between, [parseInt(min, 10), parseInt(max, 10)]);
|
||||
break;
|
||||
|
||||
case (!!min):
|
||||
message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].choice.less, parseInt(min, 10));
|
||||
break;
|
||||
|
||||
case (!!max):
|
||||
message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].choice.more, parseInt(max, 10));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return { valid: isValid, message: message };
|
||||
}
|
||||
};
|
||||
|
||||
return FormValidation.Validator.choice;
|
||||
}));
|
||||
@@ -1,172 +0,0 @@
|
||||
/**
|
||||
* color validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/color/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/color", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
color: {
|
||||
'default': 'Please enter a valid color'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.color = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
type: 'type'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
return ('color' === $field.attr('type'));
|
||||
},
|
||||
|
||||
SUPPORTED_TYPES: [
|
||||
'hex', 'rgb', 'rgba', 'hsl', 'hsla', 'keyword'
|
||||
],
|
||||
|
||||
KEYWORD_COLORS: [
|
||||
// Colors start with A
|
||||
'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure',
|
||||
// B
|
||||
'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood',
|
||||
// C
|
||||
'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan',
|
||||
// D
|
||||
'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta',
|
||||
'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue',
|
||||
'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray',
|
||||
'dimgrey', 'dodgerblue',
|
||||
// F
|
||||
'firebrick', 'floralwhite', 'forestgreen', 'fuchsia',
|
||||
// G
|
||||
'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey',
|
||||
// H
|
||||
'honeydew', 'hotpink',
|
||||
// I
|
||||
'indianred', 'indigo', 'ivory',
|
||||
// K
|
||||
'khaki',
|
||||
// L
|
||||
'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan',
|
||||
'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen',
|
||||
'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen',
|
||||
'linen',
|
||||
// M
|
||||
'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen',
|
||||
'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream',
|
||||
'mistyrose', 'moccasin',
|
||||
// N
|
||||
'navajowhite', 'navy',
|
||||
// O
|
||||
'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid',
|
||||
// P
|
||||
'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink',
|
||||
'plum', 'powderblue', 'purple',
|
||||
// R
|
||||
'red', 'rosybrown', 'royalblue',
|
||||
// S
|
||||
'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue',
|
||||
'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue',
|
||||
// T
|
||||
'tan', 'teal', 'thistle', 'tomato', 'transparent', 'turquoise',
|
||||
// V
|
||||
'violet',
|
||||
// W
|
||||
'wheat', 'white', 'whitesmoke',
|
||||
// Y
|
||||
'yellow', 'yellowgreen'
|
||||
],
|
||||
|
||||
/**
|
||||
* Return true if the input value is a valid color
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* - type: The array of valid color types
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'color');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only accept 6 hex character values due to the HTML 5 spec
|
||||
// See http://www.w3.org/TR/html-markup/input.color.html#input.color.attrs.value
|
||||
if (this.enableByHtml5($field)) {
|
||||
return /^#[0-9A-F]{6}$/i.test(value);
|
||||
}
|
||||
|
||||
var types = options.type || this.SUPPORTED_TYPES;
|
||||
if (!$.isArray(types)) {
|
||||
types = types.replace(/s/g, '').split(',');
|
||||
}
|
||||
|
||||
var method,
|
||||
type,
|
||||
isValid = false;
|
||||
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
type = types[i];
|
||||
method = '_' + type.toLowerCase();
|
||||
isValid = isValid || this[method](value);
|
||||
if (isValid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_hex: function(value) {
|
||||
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
|
||||
},
|
||||
|
||||
_hsl: function(value) {
|
||||
return /^hsl\((\s*(-?\d+)\s*,)(\s*(\b(0?\d{1,2}|100)\b%)\s*,)(\s*(\b(0?\d{1,2}|100)\b%)\s*)\)$/.test(value);
|
||||
},
|
||||
|
||||
_hsla: function(value) {
|
||||
return /^hsla\((\s*(-?\d+)\s*,)(\s*(\b(0?\d{1,2}|100)\b%)\s*,){2}(\s*(0?(\.\d+)?|1(\.0+)?)\s*)\)$/.test(value);
|
||||
},
|
||||
|
||||
_keyword: function(value) {
|
||||
return $.inArray(value, this.KEYWORD_COLORS) >= 0;
|
||||
},
|
||||
|
||||
_rgb: function(value) {
|
||||
var regexInteger = /^rgb\((\s*(\b([01]?\d{1,2}|2[0-4]\d|25[0-5])\b)\s*,){2}(\s*(\b([01]?\d{1,2}|2[0-4]\d|25[0-5])\b)\s*)\)$/,
|
||||
regexPercent = /^rgb\((\s*(\b(0?\d{1,2}|100)\b%)\s*,){2}(\s*(\b(0?\d{1,2}|100)\b%)\s*)\)$/;
|
||||
return regexInteger.test(value) || regexPercent.test(value);
|
||||
},
|
||||
|
||||
_rgba: function(value) {
|
||||
var regexInteger = /^rgba\((\s*(\b([01]?\d{1,2}|2[0-4]\d|25[0-5])\b)\s*,){3}(\s*(0?(\.\d+)?|1(\.0+)?)\s*)\)$/,
|
||||
regexPercent = /^rgba\((\s*(\b(0?\d{1,2}|100)\b%)\s*,){3}(\s*(0?(\.\d+)?|1(\.0+)?)\s*)\)$/;
|
||||
return regexInteger.test(value) || regexPercent.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.color;
|
||||
}));
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* confirm validator
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/confirm", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
confirm: {
|
||||
'default': 'Please input the same value'
|
||||
}
|
||||
}
|
||||
});
|
||||
FormValidation.Validator.confirm = {
|
||||
validate: function(validator, $field, options) {
|
||||
if (options.original.val() == $field.val() || $field.val()== '')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}));
|
||||
@@ -1,134 +0,0 @@
|
||||
/**
|
||||
* creditCard validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/creditCard/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/creditCard", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
creditCard: {
|
||||
'default': 'Please enter a valid credit card number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.creditCard = {
|
||||
/**
|
||||
* Return true if the input value is valid credit card number
|
||||
* Based on https://gist.github.com/DiegoSalazar/4075533
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} [options] Can consist of the following key:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'creditCard');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Accept only digits, dashes or spaces
|
||||
if (/[^0-9-\s]+/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
value = value.replace(/\D/g, '');
|
||||
|
||||
if (!FormValidation.Helper.luhn(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate the card number based on prefix (IIN ranges) and length
|
||||
var cards = {
|
||||
AMERICAN_EXPRESS: {
|
||||
length: [15],
|
||||
prefix: ['34', '37']
|
||||
},
|
||||
DINERS_CLUB: {
|
||||
length: [14],
|
||||
prefix: ['300', '301', '302', '303', '304', '305', '36']
|
||||
},
|
||||
DINERS_CLUB_US: {
|
||||
length: [16],
|
||||
prefix: ['54', '55']
|
||||
},
|
||||
DISCOVER: {
|
||||
length: [16],
|
||||
prefix: ['6011', '622126', '622127', '622128', '622129', '62213',
|
||||
'62214', '62215', '62216', '62217', '62218', '62219',
|
||||
'6222', '6223', '6224', '6225', '6226', '6227', '6228',
|
||||
'62290', '62291', '622920', '622921', '622922', '622923',
|
||||
'622924', '622925', '644', '645', '646', '647', '648',
|
||||
'649', '65']
|
||||
},
|
||||
JCB: {
|
||||
length: [16],
|
||||
prefix: ['3528', '3529', '353', '354', '355', '356', '357', '358']
|
||||
},
|
||||
LASER: {
|
||||
length: [16, 17, 18, 19],
|
||||
prefix: ['6304', '6706', '6771', '6709']
|
||||
},
|
||||
MAESTRO: {
|
||||
length: [12, 13, 14, 15, 16, 17, 18, 19],
|
||||
prefix: ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766']
|
||||
},
|
||||
MASTERCARD: {
|
||||
length: [16],
|
||||
prefix: ['51', '52', '53', '54', '55']
|
||||
},
|
||||
SOLO: {
|
||||
length: [16, 18, 19],
|
||||
prefix: ['6334', '6767']
|
||||
},
|
||||
UNIONPAY: {
|
||||
length: [16, 17, 18, 19],
|
||||
prefix: ['622126', '622127', '622128', '622129', '62213', '62214',
|
||||
'62215', '62216', '62217', '62218', '62219', '6222', '6223',
|
||||
'6224', '6225', '6226', '6227', '6228', '62290', '62291',
|
||||
'622920', '622921', '622922', '622923', '622924', '622925']
|
||||
},
|
||||
VISA: {
|
||||
length: [16],
|
||||
prefix: ['4']
|
||||
}
|
||||
};
|
||||
|
||||
var type, i;
|
||||
for (type in cards) {
|
||||
for (i in cards[type].prefix) {
|
||||
if (value.substr(0, cards[type].prefix[i].length) === cards[type].prefix[i] // Check the prefix
|
||||
&& $.inArray(value.length, cards[type].length) !== -1) // and length
|
||||
{
|
||||
return {
|
||||
valid: true,
|
||||
type: type
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.creditCard;
|
||||
}));
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* cusip validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/cusip/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/cusip", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
cusip: {
|
||||
'default': 'Please enter a valid CUSIP number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.cusip = {
|
||||
/**
|
||||
* Validate a CUSIP number
|
||||
* Examples:
|
||||
* - Valid: 037833100, 931142103, 14149YAR8, 126650BG6
|
||||
* - Invalid: 31430F200, 022615AC2
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/CUSIP
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} [options] Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'cusip');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = value.toUpperCase();
|
||||
if (!/^[0-9A-Z]{9}$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var converted = $.map(value.split(''), function(item) {
|
||||
var code = item.charCodeAt(0);
|
||||
return (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0))
|
||||
// Replace A, B, C, ..., Z with 10, 11, ..., 35
|
||||
? (code - 'A'.charCodeAt(0) + 10)
|
||||
: item;
|
||||
}),
|
||||
length = converted.length,
|
||||
sum = 0;
|
||||
for (var i = 0; i < length - 1; i++) {
|
||||
var num = parseInt(converted[i], 10);
|
||||
if (i % 2 !== 0) {
|
||||
num *= 2;
|
||||
}
|
||||
if (num > 9) {
|
||||
num -= 9;
|
||||
}
|
||||
sum += num;
|
||||
}
|
||||
|
||||
sum = (10 - (sum % 10)) % 10;
|
||||
return sum === parseInt(converted[length - 1], 10);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.cusip;
|
||||
}));
|
||||
@@ -1,179 +0,0 @@
|
||||
/**
|
||||
* cvv validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/cvv/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/cvv", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
cvv: {
|
||||
'default': 'Please enter a valid CVV number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.cvv = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
ccfield: 'creditCardField'
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind the validator on the live change of the credit card field
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - creditCardField: The credit card number field
|
||||
*/
|
||||
init: function(validator, $field, options) {
|
||||
if (options.creditCardField) {
|
||||
var creditCardField = validator.getFieldElements(options.creditCardField);
|
||||
validator.onLiveChange(creditCardField, 'live_cvv', function() {
|
||||
var status = validator.getStatus($field, 'cvv');
|
||||
if (status !== validator.STATUS_NOT_VALIDATED) {
|
||||
validator.revalidateField($field);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Unbind the validator on the live change of the credit card field
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - creditCardField: The credit card number field
|
||||
*/
|
||||
destroy: function(validator, $field, options) {
|
||||
if (options.creditCardField) {
|
||||
var creditCardField = validator.getFieldElements(options.creditCardField);
|
||||
validator.offLiveChange(creditCardField, 'live_cvv');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is a valid CVV number.
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - creditCardField: The credit card number field. It can be null
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'cvv');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!/^[0-9]{3,4}$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!options.creditCardField) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the credit card number
|
||||
var creditCard = validator.getFieldElements(options.creditCardField).val();
|
||||
if (creditCard === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
creditCard = creditCard.replace(/\D/g, '');
|
||||
|
||||
// Supported credit card types
|
||||
var cards = {
|
||||
AMERICAN_EXPRESS: {
|
||||
length: [15],
|
||||
prefix: ['34', '37']
|
||||
},
|
||||
DINERS_CLUB: {
|
||||
length: [14],
|
||||
prefix: ['300', '301', '302', '303', '304', '305', '36']
|
||||
},
|
||||
DINERS_CLUB_US: {
|
||||
length: [16],
|
||||
prefix: ['54', '55']
|
||||
},
|
||||
DISCOVER: {
|
||||
length: [16],
|
||||
prefix: ['6011', '622126', '622127', '622128', '622129', '62213',
|
||||
'62214', '62215', '62216', '62217', '62218', '62219',
|
||||
'6222', '6223', '6224', '6225', '6226', '6227', '6228',
|
||||
'62290', '62291', '622920', '622921', '622922', '622923',
|
||||
'622924', '622925', '644', '645', '646', '647', '648',
|
||||
'649', '65']
|
||||
},
|
||||
JCB: {
|
||||
length: [16],
|
||||
prefix: ['3528', '3529', '353', '354', '355', '356', '357', '358']
|
||||
},
|
||||
LASER: {
|
||||
length: [16, 17, 18, 19],
|
||||
prefix: ['6304', '6706', '6771', '6709']
|
||||
},
|
||||
MAESTRO: {
|
||||
length: [12, 13, 14, 15, 16, 17, 18, 19],
|
||||
prefix: ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766']
|
||||
},
|
||||
MASTERCARD: {
|
||||
length: [16],
|
||||
prefix: ['51', '52', '53', '54', '55']
|
||||
},
|
||||
SOLO: {
|
||||
length: [16, 18, 19],
|
||||
prefix: ['6334', '6767']
|
||||
},
|
||||
UNIONPAY: {
|
||||
length: [16, 17, 18, 19],
|
||||
prefix: ['622126', '622127', '622128', '622129', '62213', '62214',
|
||||
'62215', '62216', '62217', '62218', '62219', '6222', '6223',
|
||||
'6224', '6225', '6226', '6227', '6228', '62290', '62291',
|
||||
'622920', '622921', '622922', '622923', '622924', '622925']
|
||||
},
|
||||
VISA: {
|
||||
length: [16],
|
||||
prefix: ['4']
|
||||
}
|
||||
};
|
||||
var type, i, creditCardType = null;
|
||||
for (type in cards) {
|
||||
for (i in cards[type].prefix) {
|
||||
if (creditCard.substr(0, cards[type].prefix[i].length) === cards[type].prefix[i] // Check the prefix
|
||||
&& $.inArray(creditCard.length, cards[type].length) !== -1) // and length
|
||||
{
|
||||
creditCardType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (creditCardType === null)
|
||||
? false
|
||||
: (('AMERICAN_EXPRESS' === creditCardType) ? (value.length === 4) : (value.length === 3));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.cvv;
|
||||
}));
|
||||
@@ -1,381 +0,0 @@
|
||||
/**
|
||||
* date validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/date/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/date", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
date: {
|
||||
'default': 'Please enter a valid date',
|
||||
min: 'Please enter a date after %s',
|
||||
max: 'Please enter a date before %s',
|
||||
range: 'Please enter a date in the range %s - %s'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.date = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
format: 'format',
|
||||
min: 'min',
|
||||
max: 'max',
|
||||
separator: 'separator'
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is valid date
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* - min: the minimum date
|
||||
* - max: the maximum date
|
||||
* - separator: Use to separate the date, month, and year.
|
||||
* By default, it is /
|
||||
* - format: The date format. Default is MM/DD/YYYY
|
||||
* The format can be:
|
||||
*
|
||||
* i) date: Consist of DD, MM, YYYY parts which are separated by the separator option
|
||||
* ii) date and time:
|
||||
* The time can consist of h, m, s parts which are separated by :
|
||||
* ii) date, time and A (indicating AM or PM)
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'date');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
options.format = options.format || 'MM/DD/YYYY';
|
||||
|
||||
// #683: Force the format to YYYY-MM-DD as the default browser behaviour when using type="date" attribute
|
||||
if ($field.attr('type') === 'date') {
|
||||
options.format = 'YYYY-MM-DD';
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
message = options.message || FormValidation.I18n[locale].date['default'],
|
||||
formats = options.format.split(' '),
|
||||
dateFormat = formats[0],
|
||||
timeFormat = (formats.length > 1) ? formats[1] : null,
|
||||
amOrPm = (formats.length > 2) ? formats[2] : null,
|
||||
sections = value.split(' '),
|
||||
date = sections[0],
|
||||
time = (sections.length > 1) ? sections[1] : null;
|
||||
|
||||
if (formats.length !== sections.length) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
|
||||
// Determine the separator
|
||||
var separator = options.separator;
|
||||
if (!separator) {
|
||||
separator = (date.indexOf('/') !== -1) ? '/' : ((date.indexOf('-') !== -1) ? '-' : null);
|
||||
}
|
||||
if (separator === null || date.indexOf(separator) === -1) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
|
||||
// Determine the date
|
||||
date = date.split(separator);
|
||||
dateFormat = dateFormat.split(separator);
|
||||
if (date.length !== dateFormat.length) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
|
||||
var year = date[$.inArray('YYYY', dateFormat)],
|
||||
month = date[$.inArray('MM', dateFormat)],
|
||||
day = date[$.inArray('DD', dateFormat)];
|
||||
|
||||
if (!year || !month || !day || year.length !== 4) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
|
||||
// Determine the time
|
||||
var minutes = null, hours = null, seconds = null;
|
||||
if (timeFormat) {
|
||||
timeFormat = timeFormat.split(':');
|
||||
time = time.split(':');
|
||||
|
||||
if (timeFormat.length !== time.length) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
|
||||
hours = time.length > 0 ? time[0] : null;
|
||||
minutes = time.length > 1 ? time[1] : null;
|
||||
seconds = time.length > 2 ? time[2] : null;
|
||||
|
||||
if (hours === '' || minutes === '' || seconds === '') {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
|
||||
// Validate seconds
|
||||
if (seconds) {
|
||||
if (isNaN(seconds) || seconds.length > 2) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
seconds = parseInt(seconds, 10);
|
||||
if (seconds < 0 || seconds > 60) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Validate hours
|
||||
if (hours) {
|
||||
if (isNaN(hours) || hours.length > 2) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
hours = parseInt(hours, 10);
|
||||
if (hours < 0 || hours >= 24 || (amOrPm && hours > 12)) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Validate minutes
|
||||
if (minutes) {
|
||||
if (isNaN(minutes) || minutes.length > 2) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
minutes = parseInt(minutes, 10);
|
||||
if (minutes < 0 || minutes > 59) {
|
||||
return {
|
||||
valid: false,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate day, month, and year
|
||||
var valid = FormValidation.Helper.date(year, month, day),
|
||||
// declare the date, min and max objects
|
||||
min = null,
|
||||
max = null,
|
||||
minOption = options.min,
|
||||
maxOption = options.max;
|
||||
|
||||
if (minOption) {
|
||||
if (isNaN(Date.parse(minOption))) {
|
||||
minOption = validator.getDynamicOption($field, minOption);
|
||||
}
|
||||
|
||||
min = minOption instanceof Date ? minOption : this._parseDate(minOption, dateFormat, separator);
|
||||
// In order to avoid displaying a date string like "Mon Dec 08 2014 19:14:12 GMT+0000 (WET)"
|
||||
minOption = minOption instanceof Date ? this._formatDate(minOption, options.format) : minOption;
|
||||
}
|
||||
|
||||
if (maxOption) {
|
||||
if (isNaN(Date.parse(maxOption))) {
|
||||
maxOption = validator.getDynamicOption($field, maxOption);
|
||||
}
|
||||
|
||||
max = maxOption instanceof Date ? maxOption : this._parseDate(maxOption, dateFormat, separator);
|
||||
// In order to avoid displaying a date string like "Mon Dec 08 2014 19:14:12 GMT+0000 (WET)"
|
||||
maxOption = maxOption instanceof Date ? this._formatDate(maxOption, options.format) : maxOption;
|
||||
}
|
||||
|
||||
date = new Date(year, month -1, day, hours, minutes, seconds);
|
||||
|
||||
switch (true) {
|
||||
case (minOption && !maxOption && valid):
|
||||
valid = date.getTime() >= min.getTime();
|
||||
message = options.message || FormValidation.Helper.format(FormValidation.I18n[locale].date.min, minOption);
|
||||
break;
|
||||
|
||||
case (maxOption && !minOption && valid):
|
||||
valid = date.getTime() <= max.getTime();
|
||||
message = options.message || FormValidation.Helper.format(FormValidation.I18n[locale].date.max, maxOption);
|
||||
break;
|
||||
|
||||
case (maxOption && minOption && valid):
|
||||
valid = date.getTime() <= max.getTime() && date.getTime() >= min.getTime();
|
||||
message = options.message || FormValidation.Helper.format(FormValidation.I18n[locale].date.range, [minOption, maxOption]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
valid: valid,
|
||||
message: message
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a date object after parsing the date string
|
||||
*
|
||||
* @param {String} date The date string to parse
|
||||
* @param {String} format The date format
|
||||
* The format can be:
|
||||
* - date: Consist of DD, MM, YYYY parts which are separated by the separator option
|
||||
* - date and time:
|
||||
* The time can consist of h, m, s parts which are separated by :
|
||||
* @param {String} separator The separator used to separate the date, month, and year
|
||||
* @returns {Date}
|
||||
*/
|
||||
_parseDate: function(date, format, separator) {
|
||||
var minutes = 0, hours = 0, seconds = 0,
|
||||
sections = date.split(' '),
|
||||
dateSection = sections[0],
|
||||
timeSection = (sections.length > 1) ? sections[1] : null;
|
||||
|
||||
dateSection = dateSection.split(separator);
|
||||
var year = dateSection[$.inArray('YYYY', format)],
|
||||
month = dateSection[$.inArray('MM', format)],
|
||||
day = dateSection[$.inArray('DD', format)];
|
||||
if (timeSection) {
|
||||
timeSection = timeSection.split(':');
|
||||
hours = timeSection.length > 0 ? timeSection[0] : null;
|
||||
minutes = timeSection.length > 1 ? timeSection[1] : null;
|
||||
seconds = timeSection.length > 2 ? timeSection[2] : null;
|
||||
}
|
||||
|
||||
return new Date(year, month -1, day, hours, minutes, seconds);
|
||||
},
|
||||
|
||||
/**
|
||||
* Format date
|
||||
*
|
||||
* @param {Date} date The date object to format
|
||||
* @param {String} format The date format
|
||||
* The format can consist of the following tokens:
|
||||
* d Day of the month without leading zeros (1 through 31)
|
||||
* dd Day of the month with leading zeros (01 through 31)
|
||||
* m Month without leading zeros (1 through 12)
|
||||
* mm Month with leading zeros (01 through 12)
|
||||
* yy Last two digits of year (for example: 14)
|
||||
* yyyy Full four digits of year (for example: 2014)
|
||||
* h Hours without leading zeros (1 through 12)
|
||||
* hh Hours with leading zeros (01 through 12)
|
||||
* H Hours without leading zeros (0 through 23)
|
||||
* HH Hours with leading zeros (00 through 23)
|
||||
* M Minutes without leading zeros (0 through 59)
|
||||
* MM Minutes with leading zeros (00 through 59)
|
||||
* s Seconds without leading zeros (0 through 59)
|
||||
* ss Seconds with leading zeros (00 through 59)
|
||||
* @returns {String}
|
||||
*/
|
||||
_formatDate: function(date, format) {
|
||||
format = format
|
||||
.replace(/Y/g, 'y')
|
||||
.replace(/M/g, 'm')
|
||||
.replace(/D/g, 'd')
|
||||
.replace(/:m/g, ':M')
|
||||
.replace(/:mm/g, ':MM')
|
||||
.replace(/:S/, ':s')
|
||||
.replace(/:SS/, ':ss');
|
||||
|
||||
var replacer = {
|
||||
d: function(date) {
|
||||
return date.getDate();
|
||||
},
|
||||
dd: function(date) {
|
||||
var d = date.getDate();
|
||||
return (d < 10) ? '0' + d : d;
|
||||
},
|
||||
m: function(date) {
|
||||
return date.getMonth() + 1;
|
||||
},
|
||||
mm: function(date) {
|
||||
var m = date.getMonth() + 1;
|
||||
return m < 10 ? '0' + m : m;
|
||||
},
|
||||
yy: function(date) {
|
||||
return ('' + date.getFullYear()).substr(2);
|
||||
},
|
||||
yyyy: function(date) {
|
||||
return date.getFullYear();
|
||||
},
|
||||
h: function(date) {
|
||||
return date.getHours() % 12 || 12;
|
||||
},
|
||||
hh: function(date) {
|
||||
var h = date.getHours() % 12 || 12;
|
||||
return h < 10 ? '0' + h : h;
|
||||
},
|
||||
H: function(date) {
|
||||
return date.getHours();
|
||||
},
|
||||
HH: function(date) {
|
||||
var H = date.getHours();
|
||||
return H < 10 ? '0' + H : H;
|
||||
},
|
||||
M: function(date) {
|
||||
return date.getMinutes();
|
||||
},
|
||||
MM: function(date) {
|
||||
var M = date.getMinutes();
|
||||
return M < 10 ? '0' + M : M;
|
||||
},
|
||||
s: function(date) {
|
||||
return date.getSeconds();
|
||||
},
|
||||
ss: function(date) {
|
||||
var s = date.getSeconds();
|
||||
return s < 10 ? '0' + s : s;
|
||||
}
|
||||
};
|
||||
|
||||
return format.replace(/d{1,4}|m{1,4}|yy(?:yy)?|([HhMs])\1?|"[^"]*"|'[^']*'/g, function(match) {
|
||||
return replacer[match] ? replacer[match](date) : match.slice(1, match.length - 1);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.date;
|
||||
}));
|
||||
@@ -1,113 +0,0 @@
|
||||
/**
|
||||
* different validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/different/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/different", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
different: {
|
||||
'default': 'Please enter a different value'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.different = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
field: 'field'
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind the validator on the live change of the field to compare with current one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - field: The name of field that will be used to compare with current one
|
||||
*/
|
||||
init: function(validator, $field, options) {
|
||||
var fields = options.field.split(',');
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
var compareWith = validator.getFieldElements(fields[i]);
|
||||
validator.onLiveChange(compareWith, 'live_different', function() {
|
||||
var status = validator.getStatus($field, 'different');
|
||||
if (status !== validator.STATUS_NOT_VALIDATED) {
|
||||
validator.revalidateField($field);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Unbind the validator on the live change of the field to compare with current one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - field: The name of field that will be used to compare with current one
|
||||
*/
|
||||
destroy: function(validator, $field, options) {
|
||||
var fields = options.field.split(',');
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
var compareWith = validator.getFieldElements(fields[i]);
|
||||
validator.offLiveChange(compareWith, 'live_different');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is different with given field's value
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - field: The name of field that will be used to compare with current one
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'different');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var fields = options.field.split(','),
|
||||
isValid = true;
|
||||
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
var compareWith = validator.getFieldElements(fields[i]);
|
||||
if (compareWith == null || compareWith.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var compareValue = validator.getFieldValue(compareWith, 'different');
|
||||
if (value === compareValue) {
|
||||
isValid = false;
|
||||
} else if (compareValue !== '') {
|
||||
validator.updateStatus(compareWith, validator.STATUS_VALID, 'different');
|
||||
}
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.different;
|
||||
}));
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* digits validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/digits/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/digits", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
digits: {
|
||||
'default': 'Please enter only digits'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.digits = {
|
||||
/**
|
||||
* Return true if the input value contains digits only
|
||||
*
|
||||
* @param {FormValidation.Base} validator Validate plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} [options]
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'digits');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return /^\d+$/.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.digits;
|
||||
}));
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* ean validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/ean/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/ean", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
ean: {
|
||||
'default': 'Please enter a valid EAN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.ean = {
|
||||
/**
|
||||
* Validate EAN (International Article Number)
|
||||
* Examples:
|
||||
* - Valid: 73513537, 9780471117094, 4006381333931
|
||||
* - Invalid: 73513536
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/European_Article_Number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'ean');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!/^(\d{8}|\d{12}|\d{13})$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var length = value.length,
|
||||
sum = 0,
|
||||
weight = (length === 8) ? [3, 1] : [1, 3];
|
||||
for (var i = 0; i < length - 1; i++) {
|
||||
sum += parseInt(value.charAt(i), 10) * weight[i % 2];
|
||||
}
|
||||
sum = (10 - sum % 10) % 10;
|
||||
return (sum + '' === value.charAt(length - 1));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.ean;
|
||||
}));
|
||||
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* ein validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/ein/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/ein", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
ein: {
|
||||
'default': 'Please enter a valid EIN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.ein = {
|
||||
// The first two digits are called campus
|
||||
// See http://en.wikipedia.org/wiki/Employer_Identification_Number
|
||||
// http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes
|
||||
CAMPUS: {
|
||||
ANDOVER: ['10', '12'],
|
||||
ATLANTA: ['60', '67'],
|
||||
AUSTIN: ['50', '53'],
|
||||
BROOKHAVEN: ['01', '02', '03', '04', '05', '06', '11', '13', '14', '16', '21', '22', '23', '25', '34', '51', '52', '54', '55', '56', '57', '58', '59', '65'],
|
||||
CINCINNATI: ['30', '32', '35', '36', '37', '38', '61'],
|
||||
FRESNO: ['15', '24'],
|
||||
KANSAS_CITY: ['40', '44'],
|
||||
MEMPHIS: ['94', '95'],
|
||||
OGDEN: ['80', '90'],
|
||||
PHILADELPHIA: ['33', '39', '41', '42', '43', '46', '48', '62', '63', '64', '66', '68', '71', '72', '73', '74', '75', '76', '77', '81', '82', '83', '84', '85', '86', '87', '88', '91', '92', '93', '98', '99'],
|
||||
INTERNET: ['20', '26', '27', '45', '46'],
|
||||
SMALL_BUSINESS_ADMINISTRATION: ['31']
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate EIN (Employer Identification Number) which is also known as
|
||||
* Federal Employer Identification Number (FEIN) or Federal Tax Identification Number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Object|Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'ein');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!/^[0-9]{2}-?[0-9]{7}$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
// Check the first two digits
|
||||
var campus = value.substr(0, 2) + '';
|
||||
for (var key in this.CAMPUS) {
|
||||
if ($.inArray(campus, this.CAMPUS[key]) !== -1) {
|
||||
return {
|
||||
valid: true,
|
||||
campus: key
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.ein;
|
||||
}));
|
||||
@@ -1,115 +0,0 @@
|
||||
/**
|
||||
* emailAddress validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/emailAddress/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/emailAddress", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
emailAddress: {
|
||||
'default': 'Please enter a valid email address'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.emailAddress = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
multiple: 'multiple',
|
||||
separator: 'separator'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
return ('email' === $field.attr('type'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if and only if the input value is a valid email address
|
||||
*
|
||||
* @param {FormValidation.Base} validator Validate plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} [options]
|
||||
* - multiple: Allow multiple email addresses, separated by a comma or semicolon; default is false.
|
||||
* - separator: Regex for character or characters expected as separator between addresses; default is comma /[,;]/, i.e. comma or semicolon.
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'emailAddress');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Email address regular expression
|
||||
// http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
||||
var emailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
|
||||
allowMultiple = options.multiple === true || options.multiple === 'true';
|
||||
|
||||
if (allowMultiple) {
|
||||
var separator = options.separator || /[,;]/,
|
||||
addresses = this._splitEmailAddresses(value, separator);
|
||||
|
||||
for (var i = 0; i < addresses.length; i++) {
|
||||
if (!emailRegExp.test(addresses[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return emailRegExp.test(value);
|
||||
}
|
||||
},
|
||||
|
||||
_splitEmailAddresses: function(emailAddresses, separator) {
|
||||
var quotedFragments = emailAddresses.split(/"/),
|
||||
quotedFragmentCount = quotedFragments.length,
|
||||
emailAddressArray = [],
|
||||
nextEmailAddress = '';
|
||||
|
||||
for (var i = 0; i < quotedFragmentCount; i++) {
|
||||
if (i % 2 === 0) {
|
||||
var splitEmailAddressFragments = quotedFragments[i].split(separator),
|
||||
splitEmailAddressFragmentCount = splitEmailAddressFragments.length;
|
||||
|
||||
if (splitEmailAddressFragmentCount === 1) {
|
||||
nextEmailAddress += splitEmailAddressFragments[0];
|
||||
} else {
|
||||
emailAddressArray.push(nextEmailAddress + splitEmailAddressFragments[0]);
|
||||
|
||||
for (var j = 1; j < splitEmailAddressFragmentCount - 1; j++) {
|
||||
emailAddressArray.push(splitEmailAddressFragments[j]);
|
||||
}
|
||||
nextEmailAddress = splitEmailAddressFragments[splitEmailAddressFragmentCount - 1];
|
||||
}
|
||||
} else {
|
||||
nextEmailAddress += '"' + quotedFragments[i];
|
||||
if (i < quotedFragmentCount - 1) {
|
||||
nextEmailAddress += '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emailAddressArray.push(nextEmailAddress);
|
||||
return emailAddressArray;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.emailAddress;
|
||||
}));
|
||||
@@ -1,116 +0,0 @@
|
||||
/**
|
||||
* file validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/file/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/file", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
file: {
|
||||
'default': 'Please choose a valid file'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.file = {
|
||||
html5Attributes: {
|
||||
extension: 'extension',
|
||||
maxfiles: 'maxFiles',
|
||||
minfiles: 'minFiles',
|
||||
maxsize: 'maxSize',
|
||||
minsize: 'minSize',
|
||||
maxtotalsize: 'maxTotalSize',
|
||||
mintotalsize: 'minTotalSize',
|
||||
message: 'message',
|
||||
type: 'type'
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate upload file. Use HTML 5 API if the browser supports
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - extension: The allowed extensions, separated by a comma
|
||||
* - maxFiles: The maximum number of files
|
||||
* - minFiles: The minimum number of files
|
||||
* - maxSize: The maximum size in bytes
|
||||
* - minSize: The minimum size in bytes
|
||||
* - maxTotalSize: The maximum size in bytes for all files
|
||||
* - minTotalSize: The minimum size in bytes for all files
|
||||
* - message: The invalid message
|
||||
* - type: The allowed MIME type, separated by a comma
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'file');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var ext,
|
||||
extensions = options.extension ? options.extension.toLowerCase().split(',') : null,
|
||||
types = options.type ? options.type.toLowerCase().split(',') : null,
|
||||
html5 = (window.File && window.FileList && window.FileReader);
|
||||
|
||||
if (html5) {
|
||||
// Get FileList instance
|
||||
var files = $field.get(0).files,
|
||||
total = files.length,
|
||||
totalSize = 0;
|
||||
|
||||
if ((options.maxFiles && total > parseInt(options.maxFiles, 10)) // Check the maxFiles
|
||||
|| (options.minFiles && total < parseInt(options.minFiles, 10))) // Check the minFiles
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < total; i++) {
|
||||
totalSize += files[i].size;
|
||||
ext = files[i].name.substr(files[i].name.lastIndexOf('.') + 1);
|
||||
|
||||
if ((options.minSize && files[i].size < parseInt(options.minSize, 10)) // Check the minSize
|
||||
|| (options.maxSize && files[i].size > parseInt(options.maxSize, 10)) // Check the maxSize
|
||||
|| (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) // Check file extension
|
||||
|| (files[i].type && types && $.inArray(files[i].type.toLowerCase(), types) === -1)) // Check file type
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((options.maxTotalSize && totalSize > parseInt(options.maxTotalSize, 10)) // Check the maxTotalSize
|
||||
|| (options.minTotalSize && totalSize < parseInt(options.minTotalSize, 10))) // Check the minTotalSize
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Check file extension
|
||||
ext = value.substr(value.lastIndexOf('.') + 1);
|
||||
if (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.file;
|
||||
}));
|
||||
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* greaterThan validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/greaterThan/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/greaterThan", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
greaterThan: {
|
||||
'default': 'Please enter a value greater than or equal to %s',
|
||||
notInclusive: 'Please enter a value greater than %s'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.greaterThan = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
value: 'value',
|
||||
inclusive: 'inclusive'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
var type = $field.attr('type'),
|
||||
min = $field.attr('min');
|
||||
if (min && type !== 'date') {
|
||||
return {
|
||||
value: min
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is greater than or equals to given number
|
||||
*
|
||||
* @param {FormValidation.Base} validator Validate plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - value: Define the number to compare with. It can be
|
||||
* - A number
|
||||
* - Name of field which its value defines the number
|
||||
* - Name of callback function that returns the number
|
||||
* - A callback function that returns the number
|
||||
*
|
||||
* - inclusive [optional]: Can be true or false. Default is true
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'greaterThan');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = this._format(value);
|
||||
if (!$.isNumeric(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
|
||||
compareToValue = this._format(compareTo);
|
||||
|
||||
value = parseFloat(value);
|
||||
return (options.inclusive === true || options.inclusive === undefined)
|
||||
? {
|
||||
valid: value >= compareToValue,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].greaterThan['default'], compareTo)
|
||||
}
|
||||
: {
|
||||
valid: value > compareToValue,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].greaterThan.notInclusive, compareTo)
|
||||
};
|
||||
},
|
||||
|
||||
_format: function(value) {
|
||||
return (value + '').replace(',', '.');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.greaterThan;
|
||||
}));
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* grid validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/grid/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/grid", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
grid: {
|
||||
'default': 'Please enter a valid GRId number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.grid = {
|
||||
/**
|
||||
* Validate GRId (Global Release Identifier)
|
||||
* Examples:
|
||||
* - Valid: A12425GABC1234002M, A1-2425G-ABC1234002-M, A1 2425G ABC1234002 M, Grid:A1-2425G-ABC1234002-M
|
||||
* - Invalid: A1-2425G-ABC1234002-Q
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Global_Release_Identifier
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'grid');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = value.toUpperCase();
|
||||
if (!/^[GRID:]*([0-9A-Z]{2})[-\s]*([0-9A-Z]{5})[-\s]*([0-9A-Z]{10})[-\s]*([0-9A-Z]{1})$/g.test(value)) {
|
||||
return false;
|
||||
}
|
||||
value = value.replace(/\s/g, '').replace(/-/g, '');
|
||||
if ('GRID:' === value.substr(0, 5)) {
|
||||
value = value.substr(5);
|
||||
}
|
||||
return FormValidation.Helper.mod37And36(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.grid;
|
||||
}));
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* hex validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/hex/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/hex", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
hex: {
|
||||
'default': 'Please enter a valid hexadecimal number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.hex = {
|
||||
/**
|
||||
* Return true if and only if the input value is a valid hexadecimal number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'hex');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return /^[0-9a-fA-F]+$/.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.hex;
|
||||
}));
|
||||
@@ -1,271 +0,0 @@
|
||||
/**
|
||||
* iban validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/iban/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/iban", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
iban: {
|
||||
'default': 'Please enter a valid IBAN number',
|
||||
country: 'Please enter a valid IBAN number in %s',
|
||||
countries: {
|
||||
AD: 'Andorra',
|
||||
AE: 'United Arab Emirates',
|
||||
AL: 'Albania',
|
||||
AO: 'Angola',
|
||||
AT: 'Austria',
|
||||
AZ: 'Azerbaijan',
|
||||
BA: 'Bosnia and Herzegovina',
|
||||
BE: 'Belgium',
|
||||
BF: 'Burkina Faso',
|
||||
BG: 'Bulgaria',
|
||||
BH: 'Bahrain',
|
||||
BI: 'Burundi',
|
||||
BJ: 'Benin',
|
||||
BR: 'Brazil',
|
||||
CH: 'Switzerland',
|
||||
CI: 'Ivory Coast',
|
||||
CM: 'Cameroon',
|
||||
CR: 'Costa Rica',
|
||||
CV: 'Cape Verde',
|
||||
CY: 'Cyprus',
|
||||
CZ: 'Czech Republic',
|
||||
DE: 'Germany',
|
||||
DK: 'Denmark',
|
||||
DO: 'Dominican Republic',
|
||||
DZ: 'Algeria',
|
||||
EE: 'Estonia',
|
||||
ES: 'Spain',
|
||||
FI: 'Finland',
|
||||
FO: 'Faroe Islands',
|
||||
FR: 'France',
|
||||
GB: 'United Kingdom',
|
||||
GE: 'Georgia',
|
||||
GI: 'Gibraltar',
|
||||
GL: 'Greenland',
|
||||
GR: 'Greece',
|
||||
GT: 'Guatemala',
|
||||
HR: 'Croatia',
|
||||
HU: 'Hungary',
|
||||
IE: 'Ireland',
|
||||
IL: 'Israel',
|
||||
IR: 'Iran',
|
||||
IS: 'Iceland',
|
||||
IT: 'Italy',
|
||||
JO: 'Jordan',
|
||||
KW: 'Kuwait',
|
||||
KZ: 'Kazakhstan',
|
||||
LB: 'Lebanon',
|
||||
LI: 'Liechtenstein',
|
||||
LT: 'Lithuania',
|
||||
LU: 'Luxembourg',
|
||||
LV: 'Latvia',
|
||||
MC: 'Monaco',
|
||||
MD: 'Moldova',
|
||||
ME: 'Montenegro',
|
||||
MG: 'Madagascar',
|
||||
MK: 'Macedonia',
|
||||
ML: 'Mali',
|
||||
MR: 'Mauritania',
|
||||
MT: 'Malta',
|
||||
MU: 'Mauritius',
|
||||
MZ: 'Mozambique',
|
||||
NL: 'Netherlands',
|
||||
NO: 'Norway',
|
||||
PK: 'Pakistan',
|
||||
PL: 'Poland',
|
||||
PS: 'Palestine',
|
||||
PT: 'Portugal',
|
||||
QA: 'Qatar',
|
||||
RO: 'Romania',
|
||||
RS: 'Serbia',
|
||||
SA: 'Saudi Arabia',
|
||||
SE: 'Sweden',
|
||||
SI: 'Slovenia',
|
||||
SK: 'Slovakia',
|
||||
SM: 'San Marino',
|
||||
SN: 'Senegal',
|
||||
TN: 'Tunisia',
|
||||
TR: 'Turkey',
|
||||
VG: 'Virgin Islands, British'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.iban = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
country: 'country'
|
||||
},
|
||||
|
||||
// http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
|
||||
// http://en.wikipedia.org/wiki/International_Bank_Account_Number#IBAN_formats_by_country
|
||||
REGEX: {
|
||||
AD: 'AD[0-9]{2}[0-9]{4}[0-9]{4}[A-Z0-9]{12}', // Andorra
|
||||
AE: 'AE[0-9]{2}[0-9]{3}[0-9]{16}', // United Arab Emirates
|
||||
AL: 'AL[0-9]{2}[0-9]{8}[A-Z0-9]{16}', // Albania
|
||||
AO: 'AO[0-9]{2}[0-9]{21}', // Angola
|
||||
AT: 'AT[0-9]{2}[0-9]{5}[0-9]{11}', // Austria
|
||||
AZ: 'AZ[0-9]{2}[A-Z]{4}[A-Z0-9]{20}', // Azerbaijan
|
||||
BA: 'BA[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{8}[0-9]{2}', // Bosnia and Herzegovina
|
||||
BE: 'BE[0-9]{2}[0-9]{3}[0-9]{7}[0-9]{2}', // Belgium
|
||||
BF: 'BF[0-9]{2}[0-9]{23}', // Burkina Faso
|
||||
BG: 'BG[0-9]{2}[A-Z]{4}[0-9]{4}[0-9]{2}[A-Z0-9]{8}', // Bulgaria
|
||||
BH: 'BH[0-9]{2}[A-Z]{4}[A-Z0-9]{14}', // Bahrain
|
||||
BI: 'BI[0-9]{2}[0-9]{12}', // Burundi
|
||||
BJ: 'BJ[0-9]{2}[A-Z]{1}[0-9]{23}', // Benin
|
||||
BR: 'BR[0-9]{2}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z][A-Z0-9]', // Brazil
|
||||
CH: 'CH[0-9]{2}[0-9]{5}[A-Z0-9]{12}', // Switzerland
|
||||
CI: 'CI[0-9]{2}[A-Z]{1}[0-9]{23}', // Ivory Coast
|
||||
CM: 'CM[0-9]{2}[0-9]{23}', // Cameroon
|
||||
CR: 'CR[0-9]{2}[0-9]{3}[0-9]{14}', // Costa Rica
|
||||
CV: 'CV[0-9]{2}[0-9]{21}', // Cape Verde
|
||||
CY: 'CY[0-9]{2}[0-9]{3}[0-9]{5}[A-Z0-9]{16}', // Cyprus
|
||||
CZ: 'CZ[0-9]{2}[0-9]{20}', // Czech Republic
|
||||
DE: 'DE[0-9]{2}[0-9]{8}[0-9]{10}', // Germany
|
||||
DK: 'DK[0-9]{2}[0-9]{14}', // Denmark
|
||||
DO: 'DO[0-9]{2}[A-Z0-9]{4}[0-9]{20}', // Dominican Republic
|
||||
DZ: 'DZ[0-9]{2}[0-9]{20}', // Algeria
|
||||
EE: 'EE[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{11}[0-9]{1}', // Estonia
|
||||
ES: 'ES[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{1}[0-9]{1}[0-9]{10}', // Spain
|
||||
FI: 'FI[0-9]{2}[0-9]{6}[0-9]{7}[0-9]{1}', // Finland
|
||||
FO: 'FO[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}', // Faroe Islands
|
||||
FR: 'FR[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}', // France
|
||||
GB: 'GB[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}', // United Kingdom
|
||||
GE: 'GE[0-9]{2}[A-Z]{2}[0-9]{16}', // Georgia
|
||||
GI: 'GI[0-9]{2}[A-Z]{4}[A-Z0-9]{15}', // Gibraltar
|
||||
GL: 'GL[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}', // Greenland
|
||||
GR: 'GR[0-9]{2}[0-9]{3}[0-9]{4}[A-Z0-9]{16}', // Greece
|
||||
GT: 'GT[0-9]{2}[A-Z0-9]{4}[A-Z0-9]{20}', // Guatemala
|
||||
HR: 'HR[0-9]{2}[0-9]{7}[0-9]{10}', // Croatia
|
||||
HU: 'HU[0-9]{2}[0-9]{3}[0-9]{4}[0-9]{1}[0-9]{15}[0-9]{1}', // Hungary
|
||||
IE: 'IE[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}', // Ireland
|
||||
IL: 'IL[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{13}', // Israel
|
||||
IR: 'IR[0-9]{2}[0-9]{22}', // Iran
|
||||
IS: 'IS[0-9]{2}[0-9]{4}[0-9]{2}[0-9]{6}[0-9]{10}', // Iceland
|
||||
IT: 'IT[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', // Italy
|
||||
JO: 'JO[0-9]{2}[A-Z]{4}[0-9]{4}[0]{8}[A-Z0-9]{10}', // Jordan
|
||||
KW: 'KW[0-9]{2}[A-Z]{4}[0-9]{22}', // Kuwait
|
||||
KZ: 'KZ[0-9]{2}[0-9]{3}[A-Z0-9]{13}', // Kazakhstan
|
||||
LB: 'LB[0-9]{2}[0-9]{4}[A-Z0-9]{20}', // Lebanon
|
||||
LI: 'LI[0-9]{2}[0-9]{5}[A-Z0-9]{12}', // Liechtenstein
|
||||
LT: 'LT[0-9]{2}[0-9]{5}[0-9]{11}', // Lithuania
|
||||
LU: 'LU[0-9]{2}[0-9]{3}[A-Z0-9]{13}', // Luxembourg
|
||||
LV: 'LV[0-9]{2}[A-Z]{4}[A-Z0-9]{13}', // Latvia
|
||||
MC: 'MC[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}', // Monaco
|
||||
MD: 'MD[0-9]{2}[A-Z0-9]{20}', // Moldova
|
||||
ME: 'ME[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Montenegro
|
||||
MG: 'MG[0-9]{2}[0-9]{23}', // Madagascar
|
||||
MK: 'MK[0-9]{2}[0-9]{3}[A-Z0-9]{10}[0-9]{2}', // Macedonia
|
||||
ML: 'ML[0-9]{2}[A-Z]{1}[0-9]{23}', // Mali
|
||||
MR: 'MR13[0-9]{5}[0-9]{5}[0-9]{11}[0-9]{2}', // Mauritania
|
||||
MT: 'MT[0-9]{2}[A-Z]{4}[0-9]{5}[A-Z0-9]{18}', // Malta
|
||||
MU: 'MU[0-9]{2}[A-Z]{4}[0-9]{2}[0-9]{2}[0-9]{12}[0-9]{3}[A-Z]{3}', // Mauritius
|
||||
MZ: 'MZ[0-9]{2}[0-9]{21}', // Mozambique
|
||||
NL: 'NL[0-9]{2}[A-Z]{4}[0-9]{10}', // Netherlands
|
||||
NO: 'NO[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{1}', // Norway
|
||||
PK: 'PK[0-9]{2}[A-Z]{4}[A-Z0-9]{16}', // Pakistan
|
||||
PL: 'PL[0-9]{2}[0-9]{8}[0-9]{16}', // Poland
|
||||
PS: 'PS[0-9]{2}[A-Z]{4}[A-Z0-9]{21}', // Palestinian
|
||||
PT: 'PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}', // Portugal
|
||||
QA: 'QA[0-9]{2}[A-Z]{4}[A-Z0-9]{21}', // Qatar
|
||||
RO: 'RO[0-9]{2}[A-Z]{4}[A-Z0-9]{16}', // Romania
|
||||
RS: 'RS[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Serbia
|
||||
SA: 'SA[0-9]{2}[0-9]{2}[A-Z0-9]{18}', // Saudi Arabia
|
||||
SE: 'SE[0-9]{2}[0-9]{3}[0-9]{16}[0-9]{1}', // Sweden
|
||||
SI: 'SI[0-9]{2}[0-9]{5}[0-9]{8}[0-9]{2}', // Slovenia
|
||||
SK: 'SK[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}', // Slovakia
|
||||
SM: 'SM[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', // San Marino
|
||||
SN: 'SN[0-9]{2}[A-Z]{1}[0-9]{23}', // Senegal
|
||||
TN: 'TN59[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Tunisia
|
||||
TR: 'TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}', // Turkey
|
||||
VG: 'VG[0-9]{2}[A-Z]{4}[0-9]{16}' // Virgin Islands, British
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate an International Bank Account Number (IBAN)
|
||||
* To test it, take the sample IBAN from
|
||||
* http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* - country: The ISO 3166-1 country code. It can be
|
||||
* - A country code
|
||||
* - Name of field which its value defines the country code
|
||||
* - Name of callback function that returns the country code
|
||||
* - A callback function that returns the country code
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'iban');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
|
||||
var country = options.country;
|
||||
if (!country) {
|
||||
country = value.substr(0, 2);
|
||||
} else if (typeof country !== 'string' || !this.REGEX[country]) {
|
||||
// Determine the country code
|
||||
country = validator.getDynamicOption($field, country);
|
||||
}
|
||||
|
||||
var locale = validator.getLocale();
|
||||
if (!this.REGEX[country]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(new RegExp('^' + this.REGEX[country] + '$')).test(value)) {
|
||||
return {
|
||||
valid: false,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].iban.country, FormValidation.I18n[locale].iban.countries[country])
|
||||
};
|
||||
}
|
||||
|
||||
value = value.substr(4) + value.substr(0, 4);
|
||||
value = $.map(value.split(''), function(n) {
|
||||
var code = n.charCodeAt(0);
|
||||
return (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0))
|
||||
// Replace A, B, C, ..., Z with 10, 11, ..., 35
|
||||
? (code - 'A'.charCodeAt(0) + 10)
|
||||
: n;
|
||||
});
|
||||
value = value.join('');
|
||||
|
||||
var temp = parseInt(value.substr(0, 1), 10),
|
||||
length = value.length;
|
||||
for (var i = 1; i < length; ++i) {
|
||||
temp = (temp * 10 + parseInt(value.substr(i, 1), 10)) % 97;
|
||||
}
|
||||
|
||||
return {
|
||||
valid: (temp === 1),
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].iban.country, FormValidation.I18n[locale].iban.countries[country])
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.iban;
|
||||
}));
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* identical validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/identical/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/identical", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
identical: {
|
||||
'default': 'Please enter the same value'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.identical = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
field: 'field'
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind the validator on the live change of the field to compare with current one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - field: The name of field that will be used to compare with current one
|
||||
*/
|
||||
init: function(validator, $field, options) {
|
||||
var compareWith = validator.getFieldElements(options.field);
|
||||
validator.onLiveChange(compareWith, 'live_identical', function() {
|
||||
var status = validator.getStatus($field, 'identical');
|
||||
if (status !== validator.STATUS_NOT_VALIDATED) {
|
||||
validator.revalidateField($field);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Unbind the validator on the live change of the field to compare with current one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - field: The name of field that will be used to compare with current one
|
||||
*/
|
||||
destroy: function(validator, $field, options) {
|
||||
var compareWith = validator.getFieldElements(options.field);
|
||||
validator.offLiveChange(compareWith, 'live_identical');
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if input value equals to value of particular one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - field: The name of field that will be used to compare with current one
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'identical'),
|
||||
compareWith = validator.getFieldElements(options.field);
|
||||
if (compareWith === null || compareWith.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var compareValue = validator.getFieldValue(compareWith, 'identical');
|
||||
if (value === compareValue) {
|
||||
validator.updateStatus(compareWith, validator.STATUS_VALID, 'identical');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.identical;
|
||||
}));
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* imei validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/imei/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/imei", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
imei: {
|
||||
'default': 'Please enter a valid IMEI number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.imei = {
|
||||
/**
|
||||
* Validate IMEI (International Mobile Station Equipment Identity)
|
||||
* Examples:
|
||||
* - Valid: 35-209900-176148-1, 35-209900-176148-23, 3568680000414120, 490154203237518
|
||||
* - Invalid: 490154203237517
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Mobile_Station_Equipment_Identity
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'imei');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case /^\d{15}$/.test(value):
|
||||
case /^\d{2}-\d{6}-\d{6}-\d{1}$/.test(value):
|
||||
case /^\d{2}\s\d{6}\s\d{6}\s\d{1}$/.test(value):
|
||||
value = value.replace(/[^0-9]/g, '');
|
||||
return FormValidation.Helper.luhn(value);
|
||||
|
||||
case /^\d{14}$/.test(value):
|
||||
case /^\d{16}$/.test(value):
|
||||
case /^\d{2}-\d{6}-\d{6}(|-\d{2})$/.test(value):
|
||||
case /^\d{2}\s\d{6}\s\d{6}(|\s\d{2})$/.test(value):
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.imei;
|
||||
}));
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* imo validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/imo/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/imo", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
imo: {
|
||||
'default': 'Please enter a valid IMO number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.imo = {
|
||||
/**
|
||||
* Validate IMO (International Maritime Organization)
|
||||
* Examples:
|
||||
* - Valid: IMO 8814275, IMO 9176187
|
||||
* - Invalid: IMO 8814274
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/IMO_Number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'imo');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!/^IMO \d{7}$/i.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Grab just the digits
|
||||
var sum = 0,
|
||||
digits = value.replace(/^.*(\d{7})$/, '$1');
|
||||
|
||||
// Go over each char, multiplying by the inverse of it's position
|
||||
// IMO 9176187
|
||||
// (9 * 7) + (1 * 6) + (7 * 5) + (6 * 4) + (1 * 3) + (8 * 2) = 147
|
||||
// Take the last digit of that, that's the check digit (7)
|
||||
for (var i = 6; i >= 1; i--) {
|
||||
sum += (digits.slice((6 - i), -i) * (i + 1));
|
||||
}
|
||||
|
||||
return sum % 10 === parseInt(digits.charAt(6), 10);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.imo;
|
||||
}));
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* integer validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/integer/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/integer", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
integer: {
|
||||
'default': 'Please enter a valid number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.integer = {
|
||||
enableByHtml5: function($field) {
|
||||
return ('number' === $field.attr('type')) && ($field.attr('step') === undefined || $field.attr('step') % 1 === 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is an integer
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following key:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
if (this.enableByHtml5($field) && $field.get(0).validity && $field.get(0).validity.badInput === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = validator.getFieldValue($field, 'integer');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
return /^(?:-?(?:0|[1-9][0-9]*))$/.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.integer;
|
||||
}));
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
* ip validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/ip/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/ip", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
ip: {
|
||||
'default': 'Please enter a valid IP address',
|
||||
ipv4: 'Please enter a valid IPv4 address',
|
||||
ipv6: 'Please enter a valid IPv6 address'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.ip = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
ipv4: 'ipv4',
|
||||
ipv6: 'ipv6'
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is a IP address.
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - ipv4: Enable IPv4 validator, default to true
|
||||
* - ipv6: Enable IPv6 validator, default to true
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'ip');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
options = $.extend({}, { ipv4: true, ipv6: true }, options);
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
||||
ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,
|
||||
valid = false,
|
||||
message;
|
||||
|
||||
switch (true) {
|
||||
case (options.ipv4 && !options.ipv6):
|
||||
valid = ipv4Regex.test(value);
|
||||
message = options.message || FormValidation.I18n[locale].ip.ipv4;
|
||||
break;
|
||||
|
||||
case (!options.ipv4 && options.ipv6):
|
||||
valid = ipv6Regex.test(value);
|
||||
message = options.message || FormValidation.I18n[locale].ip.ipv6;
|
||||
break;
|
||||
|
||||
case (options.ipv4 && options.ipv6):
|
||||
/* falls through */
|
||||
default:
|
||||
valid = ipv4Regex.test(value) || ipv6Regex.test(value);
|
||||
message = options.message || FormValidation.I18n[locale].ip['default'];
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
valid: valid,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.ip;
|
||||
}));
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* isbn validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/isbn/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/isbn", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
isbn: {
|
||||
'default': 'Please enter a valid ISBN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.isbn = {
|
||||
/**
|
||||
* Return true if the input value is a valid ISBN 10 or ISBN 13 number
|
||||
* Examples:
|
||||
* - Valid:
|
||||
* ISBN 10: 99921-58-10-7, 9971-5-0210-0, 960-425-059-0, 80-902734-1-6, 85-359-0277-5, 1-84356-028-3, 0-684-84328-5, 0-8044-2957-X, 0-85131-041-9, 0-943396-04-2, 0-9752298-0-X
|
||||
* ISBN 13: 978-0-306-40615-7
|
||||
* - Invalid:
|
||||
* ISBN 10: 99921-58-10-6
|
||||
* ISBN 13: 978-0-306-40615-6
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} [options] Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'isbn');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// http://en.wikipedia.org/wiki/International_Standard_Book_Number#Overview
|
||||
// Groups are separated by a hyphen or a space
|
||||
var type;
|
||||
switch (true) {
|
||||
case /^\d{9}[\dX]$/.test(value):
|
||||
case (value.length === 13 && /^(\d+)-(\d+)-(\d+)-([\dX])$/.test(value)):
|
||||
case (value.length === 13 && /^(\d+)\s(\d+)\s(\d+)\s([\dX])$/.test(value)):
|
||||
type = 'ISBN10';
|
||||
break;
|
||||
case /^(978|979)\d{9}[\dX]$/.test(value):
|
||||
case (value.length === 17 && /^(978|979)-(\d+)-(\d+)-(\d+)-([\dX])$/.test(value)):
|
||||
case (value.length === 17 && /^(978|979)\s(\d+)\s(\d+)\s(\d+)\s([\dX])$/.test(value)):
|
||||
type = 'ISBN13';
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
// Replace all special characters except digits and X
|
||||
value = value.replace(/[^0-9X]/gi, '');
|
||||
var chars = value.split(''),
|
||||
length = chars.length,
|
||||
sum = 0,
|
||||
i,
|
||||
checksum;
|
||||
|
||||
switch (type) {
|
||||
case 'ISBN10':
|
||||
sum = 0;
|
||||
for (i = 0; i < length - 1; i++) {
|
||||
sum += parseInt(chars[i], 10) * (10 - i);
|
||||
}
|
||||
checksum = 11 - (sum % 11);
|
||||
if (checksum === 11) {
|
||||
checksum = 0;
|
||||
} else if (checksum === 10) {
|
||||
checksum = 'X';
|
||||
}
|
||||
return (checksum + '' === chars[length - 1]);
|
||||
|
||||
case 'ISBN13':
|
||||
sum = 0;
|
||||
for (i = 0; i < length - 1; i++) {
|
||||
sum += ((i % 2 === 0) ? parseInt(chars[i], 10) : (parseInt(chars[i], 10) * 3));
|
||||
}
|
||||
checksum = 10 - (sum % 10);
|
||||
if (checksum === 10) {
|
||||
checksum = '0';
|
||||
}
|
||||
return (checksum + '' === chars[length - 1]);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.isbn;
|
||||
}));
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* isin validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/isin/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/isin", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
isin: {
|
||||
'default': 'Please enter a valid ISIN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.isin = {
|
||||
// Available country codes
|
||||
// See http://isin.net/country-codes/
|
||||
COUNTRY_CODES: 'AF|AX|AL|DZ|AS|AD|AO|AI|AQ|AG|AR|AM|AW|AU|AT|AZ|BS|BH|BD|BB|BY|BE|BZ|BJ|BM|BT|BO|BQ|BA|BW|BV|BR|IO|BN|BG|BF|BI|KH|CM|CA|CV|KY|CF|TD|CL|CN|CX|CC|CO|KM|CG|CD|CK|CR|CI|HR|CU|CW|CY|CZ|DK|DJ|DM|DO|EC|EG|SV|GQ|ER|EE|ET|FK|FO|FJ|FI|FR|GF|PF|TF|GA|GM|GE|DE|GH|GI|GR|GL|GD|GP|GU|GT|GG|GN|GW|GY|HT|HM|VA|HN|HK|HU|IS|IN|ID|IR|IQ|IE|IM|IL|IT|JM|JP|JE|JO|KZ|KE|KI|KP|KR|KW|KG|LA|LV|LB|LS|LR|LY|LI|LT|LU|MO|MK|MG|MW|MY|MV|ML|MT|MH|MQ|MR|MU|YT|MX|FM|MD|MC|MN|ME|MS|MA|MZ|MM|NA|NR|NP|NL|NC|NZ|NI|NE|NG|NU|NF|MP|NO|OM|PK|PW|PS|PA|PG|PY|PE|PH|PN|PL|PT|PR|QA|RE|RO|RU|RW|BL|SH|KN|LC|MF|PM|VC|WS|SM|ST|SA|SN|RS|SC|SL|SG|SX|SK|SI|SB|SO|ZA|GS|SS|ES|LK|SD|SR|SJ|SZ|SE|CH|SY|TW|TJ|TZ|TH|TL|TG|TK|TO|TT|TN|TR|TM|TC|TV|UG|UA|AE|GB|US|UM|UY|UZ|VU|VE|VN|VG|VI|WF|EH|YE|ZM|ZW',
|
||||
|
||||
/**
|
||||
* Validate an ISIN (International Securities Identification Number)
|
||||
* Examples:
|
||||
* - Valid: US0378331005, AU0000XVGZA3, GB0002634946
|
||||
* - Invalid: US0378331004, AA0000XVGZA3
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Securities_Identifying_Number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'isin');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = value.toUpperCase();
|
||||
var regex = new RegExp('^(' + this.COUNTRY_CODES + ')[0-9A-Z]{10}$');
|
||||
if (!regex.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var converted = '',
|
||||
length = value.length;
|
||||
// Convert letters to number
|
||||
for (var i = 0; i < length - 1; i++) {
|
||||
var c = value.charCodeAt(i);
|
||||
converted += ((c > 57) ? (c - 55).toString() : value.charAt(i));
|
||||
}
|
||||
|
||||
var digits = '',
|
||||
n = converted.length,
|
||||
group = (n % 2 !== 0) ? 0 : 1;
|
||||
for (i = 0; i < n; i++) {
|
||||
digits += (parseInt(converted[i], 10) * ((i % 2) === group ? 2 : 1) + '');
|
||||
}
|
||||
|
||||
var sum = 0;
|
||||
for (i = 0; i < digits.length; i++) {
|
||||
sum += parseInt(digits.charAt(i), 10);
|
||||
}
|
||||
sum = (10 - (sum % 10)) % 10;
|
||||
return sum + '' === value.charAt(length - 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.isin;
|
||||
}));
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* ismn validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/ismn/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/ismn", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
ismn: {
|
||||
'default': 'Please enter a valid ISMN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.ismn = {
|
||||
/**
|
||||
* Validate ISMN (International Standard Music Number)
|
||||
* Examples:
|
||||
* - Valid: M230671187, 979-0-0601-1561-5, 979 0 3452 4680 5, 9790060115615
|
||||
* - Invalid: 9790060115614
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Standard_Music_Number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'ismn');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Groups are separated by a hyphen or a space
|
||||
var type;
|
||||
switch (true) {
|
||||
case /^M\d{9}$/.test(value):
|
||||
case /^M-\d{4}-\d{4}-\d{1}$/.test(value):
|
||||
case /^M\s\d{4}\s\d{4}\s\d{1}$/.test(value):
|
||||
type = 'ISMN10';
|
||||
break;
|
||||
case /^9790\d{9}$/.test(value):
|
||||
case /^979-0-\d{4}-\d{4}-\d{1}$/.test(value):
|
||||
case /^979\s0\s\d{4}\s\d{4}\s\d{1}$/.test(value):
|
||||
type = 'ISMN13';
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('ISMN10' === type) {
|
||||
value = '9790' + value.substr(1);
|
||||
}
|
||||
|
||||
// Replace all special characters except digits
|
||||
value = value.replace(/[^0-9]/gi, '');
|
||||
var length = value.length,
|
||||
sum = 0,
|
||||
weight = [1, 3];
|
||||
for (var i = 0; i < length - 1; i++) {
|
||||
sum += parseInt(value.charAt(i), 10) * weight[i % 2];
|
||||
}
|
||||
sum = 10 - sum % 10;
|
||||
return (sum + '' === value.charAt(length - 1));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.ismn;
|
||||
}));
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* issn validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/issn/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/issn", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
issn: {
|
||||
'default': 'Please enter a valid ISSN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.issn = {
|
||||
/**
|
||||
* Validate ISSN (International Standard Serial Number)
|
||||
* Examples:
|
||||
* - Valid: 0378-5955, 0024-9319, 0032-1478
|
||||
* - Invalid: 0032-147X
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Standard_Serial_Number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'issn');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Groups are separated by a hyphen or a space
|
||||
if (!/^\d{4}\-\d{3}[\dX]$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Replace all special characters except digits and X
|
||||
value = value.replace(/[^0-9X]/gi, '');
|
||||
var chars = value.split(''),
|
||||
length = chars.length,
|
||||
sum = 0;
|
||||
|
||||
if (chars[7] === 'X') {
|
||||
chars[7] = 10;
|
||||
}
|
||||
for (var i = 0; i < length; i++) {
|
||||
sum += parseInt(chars[i], 10) * (8 - i);
|
||||
}
|
||||
return (sum % 11 === 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.issn;
|
||||
}));
|
||||
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* lessThan validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/lessThan/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/lessThan", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
lessThan: {
|
||||
'default': 'Please enter a value less than or equal to %s',
|
||||
notInclusive: 'Please enter a value less than %s'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.lessThan = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
value: 'value',
|
||||
inclusive: 'inclusive'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
var type = $field.attr('type'),
|
||||
max = $field.attr('max');
|
||||
if (max && type !== 'date') {
|
||||
return {
|
||||
value: max
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is less than or equal to given number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - value: The number used to compare to. It can be
|
||||
* - A number
|
||||
* - Name of field which its value defines the number
|
||||
* - Name of callback function that returns the number
|
||||
* - A callback function that returns the number
|
||||
*
|
||||
* - inclusive [optional]: Can be true or false. Default is true
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'lessThan');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = this._format(value);
|
||||
if (!$.isNumeric(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
|
||||
compareToValue = this._format(compareTo);
|
||||
|
||||
value = parseFloat(value);
|
||||
return (options.inclusive === true || options.inclusive === undefined)
|
||||
? {
|
||||
valid: value <= compareToValue,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].lessThan['default'], compareTo)
|
||||
}
|
||||
: {
|
||||
valid: value < compareToValue,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].lessThan.notInclusive, compareTo)
|
||||
};
|
||||
},
|
||||
|
||||
_format: function(value) {
|
||||
return (value + '').replace(',', '.');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.lessThan;
|
||||
}));
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* mac validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/mac/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/mac", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
mac: {
|
||||
'default': 'Please enter a valid MAC address'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.mac = {
|
||||
/**
|
||||
* Return true if the input value is a MAC address.
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'mac');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.mac;
|
||||
}));
|
||||
@@ -1,111 +0,0 @@
|
||||
/**
|
||||
* meid validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/meid/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/meid", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
meid: {
|
||||
'default': 'Please enter a valid MEID number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.meid = {
|
||||
/**
|
||||
* Validate MEID (Mobile Equipment Identifier)
|
||||
* Examples:
|
||||
* - Valid: 293608736500703710, 29360-87365-0070-3710, AF0123450ABCDE, AF-012345-0ABCDE
|
||||
* - Invalid: 2936087365007037101
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Mobile_equipment_identifier
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'meid');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
// 14 digit hex representation (no check digit)
|
||||
case /^[0-9A-F]{15}$/i.test(value):
|
||||
// 14 digit hex representation + dashes or spaces (no check digit)
|
||||
case /^[0-9A-F]{2}[- ][0-9A-F]{6}[- ][0-9A-F]{6}[- ][0-9A-F]$/i.test(value):
|
||||
// 18 digit decimal representation (no check digit)
|
||||
case /^\d{19}$/.test(value):
|
||||
// 18 digit decimal representation + dashes or spaces (no check digit)
|
||||
case /^\d{5}[- ]\d{5}[- ]\d{4}[- ]\d{4}[- ]\d$/.test(value):
|
||||
// Grab the check digit
|
||||
var cd = value.charAt(value.length - 1);
|
||||
|
||||
// Strip any non-hex chars
|
||||
value = value.replace(/[- ]/g, '');
|
||||
|
||||
// If it's all digits, luhn base 10 is used
|
||||
if (value.match(/^\d*$/i)) {
|
||||
return FormValidation.Helper.luhn(value);
|
||||
}
|
||||
|
||||
// Strip the check digit
|
||||
value = value.slice(0, -1);
|
||||
|
||||
// Get every other char, and double it
|
||||
var cdCalc = '';
|
||||
for (var i = 1; i <= 13; i += 2) {
|
||||
cdCalc += (parseInt(value.charAt(i), 16) * 2).toString(16);
|
||||
}
|
||||
|
||||
// Get the sum of each char in the string
|
||||
var sum = 0;
|
||||
for (i = 0; i < cdCalc.length; i++) {
|
||||
sum += parseInt(cdCalc.charAt(i), 16);
|
||||
}
|
||||
|
||||
// If the last digit of the calc is 0, the check digit is 0
|
||||
return (sum % 10 === 0)
|
||||
? (cd === '0')
|
||||
// Subtract it from the next highest 10s number (64 goes to 70) and subtract the sum
|
||||
// Double it and turn it into a hex char
|
||||
: (cd === ((Math.floor((sum + 10) / 10) * 10 - sum) * 2).toString(16));
|
||||
|
||||
// 14 digit hex representation (no check digit)
|
||||
case /^[0-9A-F]{14}$/i.test(value):
|
||||
// 14 digit hex representation + dashes or spaces (no check digit)
|
||||
case /^[0-9A-F]{2}[- ][0-9A-F]{6}[- ][0-9A-F]{6}$/i.test(value):
|
||||
// 18 digit decimal representation (no check digit)
|
||||
case /^\d{18}$/.test(value):
|
||||
// 18 digit decimal representation + dashes or spaces (no check digit)
|
||||
case /^\d{5}[- ]\d{5}[- ]\d{4}[- ]\d{4}$/.test(value):
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.meid;
|
||||
}));
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* notEmpty validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/notEmpty/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/notEmpty", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
notEmpty: {
|
||||
'default': 'Please enter a value'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.notEmpty = {
|
||||
enableByHtml5: function($field) {
|
||||
var required = $field.attr('required') + '';
|
||||
return ('required' === required || 'true' === required);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if input value is empty or not
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var type = $field.attr('type');
|
||||
if ('radio' === type || 'checkbox' === type) {
|
||||
var ns = validator.getNamespace();
|
||||
return validator
|
||||
.getFieldElements($field.attr('data-' + ns + '-field'))
|
||||
.filter(':checked')
|
||||
.length > 0;
|
||||
}
|
||||
|
||||
if ('number' === type && $field.get(0).validity && $field.get(0).validity.badInput === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $.trim($field.val()) !== '';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.notEmpty;
|
||||
}));
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* numeric validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/numeric/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/numeric", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
numeric: {
|
||||
'default': 'Please enter a valid float number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.numeric = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
separator: 'separator'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
return ('number' === $field.attr('type')) && ($field.attr('step') !== undefined) && ($field.attr('step') % 1 !== 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate decimal number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* - separator: The decimal separator. Can be "." (default), ","
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
if (this.enableByHtml5($field) && $field.get(0).validity && $field.get(0).validity.badInput === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = validator.getFieldValue($field, 'numeric');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
var separator = options.separator || '.';
|
||||
if (separator !== '.') {
|
||||
value = value.replace(separator, '.');
|
||||
}
|
||||
|
||||
return !isNaN(parseFloat(value)) && isFinite(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.numeric;
|
||||
}));
|
||||
@@ -1,243 +0,0 @@
|
||||
/**
|
||||
* phone validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/phone/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/phone", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
phone: {
|
||||
'default': 'Please enter a valid phone number',
|
||||
country: 'Please enter a valid phone number in %s',
|
||||
countries: {
|
||||
AE: 'United Arab Emirates',
|
||||
BG: 'Bulgaria',
|
||||
BR: 'Brazil',
|
||||
CN: 'China',
|
||||
CZ: 'Czech Republic',
|
||||
DE: 'Germany',
|
||||
DK: 'Denmark',
|
||||
ES: 'Spain',
|
||||
FR: 'France',
|
||||
GB: 'United Kingdom',
|
||||
IN: 'India',
|
||||
MA: 'Morocco',
|
||||
NL: 'Netherlands',
|
||||
PK: 'Pakistan',
|
||||
RO: 'Romania',
|
||||
RU: 'Russia',
|
||||
SK: 'Slovakia',
|
||||
TH: 'Thailand',
|
||||
US: 'USA',
|
||||
VE: 'Venezuela'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.phone = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
country: 'country'
|
||||
},
|
||||
|
||||
// The supported countries
|
||||
COUNTRY_CODES: ['AE', 'BG', 'BR', 'CN', 'CZ', 'DE', 'DK', 'ES', 'FR', 'GB', 'IN', 'MA', 'NL', 'PK', 'RO', 'RU', 'SK', 'TH', 'US', 'VE'],
|
||||
|
||||
/**
|
||||
* Return true if the input value contains a valid phone number for the country
|
||||
* selected in the options
|
||||
*
|
||||
* @param {FormValidation.Base} validator Validate plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* - country: The ISO-3166 country code. It can be
|
||||
* - A country code
|
||||
* - Name of field which its value defines the country code
|
||||
* - Name of callback function that returns the country code
|
||||
* - A callback function that returns the country code
|
||||
*
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'phone');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
country = options.country;
|
||||
if (typeof country !== 'string' || $.inArray(country, this.COUNTRY_CODES) === -1) {
|
||||
// Try to determine the country
|
||||
country = validator.getDynamicOption($field, country);
|
||||
}
|
||||
|
||||
if (!country || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var isValid = true;
|
||||
switch (country.toUpperCase()) {
|
||||
case 'AE':
|
||||
// Test: http://regexr.com/39tak
|
||||
value = $.trim(value);
|
||||
isValid = (/^(((\+|00)?971[\s\.-]?(\(0\)[\s\.-]?)?|0)(\(5(0|2|5|6)\)|5(0|2|5|6)|2|3|4|6|7|9)|60)([\s\.-]?[0-9]){7}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'BG':
|
||||
// Test cases can be found here: https://regex101.com/r/yE6vN4/1
|
||||
// See http://en.wikipedia.org/wiki/Telephone_numbers_in_Bulgaria
|
||||
value = value.replace(/\+|\s|-|\/|\(|\)/gi,'');
|
||||
isValid = (/^(0|359|00)(((700|900)[0-9]{5}|((800)[0-9]{5}|(800)[0-9]{4}))|(87|88|89)([0-9]{7})|((2[0-9]{7})|(([3-9][0-9])(([0-9]{6})|([0-9]{5})))))$/).test(value);
|
||||
break;
|
||||
|
||||
case 'BR':
|
||||
// Test: http://regexr.com/399m1
|
||||
value = $.trim(value);
|
||||
isValid = (/^(([\d]{4}[-.\s]{1}[\d]{2,3}[-.\s]{1}[\d]{2}[-.\s]{1}[\d]{2})|([\d]{4}[-.\s]{1}[\d]{3}[-.\s]{1}[\d]{4})|((\(?\+?[0-9]{2}\)?\s?)?(\(?\d{2}\)?\s?)?\d{4,5}[-.\s]?\d{4}))$/).test(value);
|
||||
break;
|
||||
|
||||
case 'CN':
|
||||
// http://regexr.com/39dq4
|
||||
value = $.trim(value);
|
||||
isValid = (/^((00|\+)?(86(?:-| )))?((\d{11})|(\d{3}[- ]{1}\d{4}[- ]{1}\d{4})|((\d{2,4}[- ]){1}(\d{7,8}|(\d{3,4}[- ]{1}\d{4}))([- ]{1}\d{1,4})?))$/).test(value);
|
||||
break;
|
||||
|
||||
case 'CZ':
|
||||
// Test: http://regexr.com/39hhl
|
||||
isValid = /^(((00)([- ]?)|\+)(420)([- ]?))?((\d{3})([- ]?)){2}(\d{3})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'DE':
|
||||
// Test: http://regexr.com/39pkg
|
||||
value = $.trim(value);
|
||||
isValid = (/^(((((((00|\+)49[ \-/]?)|0)[1-9][0-9]{1,4})[ \-/]?)|((((00|\+)49\()|\(0)[1-9][0-9]{1,4}\)[ \-/]?))[0-9]{1,7}([ \-/]?[0-9]{1,5})?)$/).test(value);
|
||||
break;
|
||||
|
||||
case 'DK':
|
||||
// Mathing DK phone numbers with country code in 1 of 3 formats and an
|
||||
// 8 digit phone number not starting with a 0 or 1. Can have 1 space
|
||||
// between each character except inside the country code.
|
||||
// Test: http://regex101.com/r/sS8fO4/1
|
||||
value = $.trim(value);
|
||||
isValid = (/^(\+45|0045|\(45\))?\s?[2-9](\s?\d){7}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'ES':
|
||||
// http://regex101.com/r/rB9mA9/1
|
||||
// Telephone numbers in Spain go like this:
|
||||
// 9: Landline phones and special prefixes.
|
||||
// 6, 7: Mobile phones.
|
||||
// 5: VoIP lines.
|
||||
// 8: Premium-rate services.
|
||||
// There are also special 5-digit and 3-digit numbers, but
|
||||
// maybe it would be overkill to include them all.
|
||||
value = $.trim(value);
|
||||
isValid = (/^(?:(?:(?:\+|00)34\D?))?(?:5|6|7|8|9)(?:\d\D?){8}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'FR':
|
||||
// http://regexr.com/39a2p
|
||||
value = $.trim(value);
|
||||
isValid = (/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'GB':
|
||||
// http://aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers#Match_GB_telephone_number_in_any_format
|
||||
// Test: http://regexr.com/38uhv
|
||||
value = $.trim(value);
|
||||
isValid = (/^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|0)(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}|\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4}|\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3})|\d{5}\)?[\s-]?\d{4,5}|8(?:00[\s-]?11[\s-]?11|45[\s-]?46[\s-]?4\d))(?:(?:[\s-]?(?:x|ext\.?\s?|\#)\d+)?)$/).test(value);
|
||||
break;
|
||||
|
||||
case 'IN':
|
||||
// http://stackoverflow.com/questions/18351553/regular-expression-validation-for-indian-phone-number-and-mobile-number
|
||||
// Test: http://regex101.com/r/qL6eZ5/1
|
||||
// May begin with +91. Supports mobile and land line numbers
|
||||
value = $.trim(value);
|
||||
isValid = (/((\+?)((0[ -]+)*|(91 )*)(\d{12}|\d{10}))|\d{5}([- ]*)\d{6}/).test(value);
|
||||
break;
|
||||
|
||||
case 'MA':
|
||||
// http://en.wikipedia.org/wiki/Telephone_numbers_in_Morocco
|
||||
// Test: http://regexr.com/399n8
|
||||
value = $.trim(value);
|
||||
isValid = (/^(?:(?:(?:\+|00)212[\s]?(?:[\s]?\(0\)[\s]?)?)|0){1}(?:5[\s.-]?[2-3]|6[\s.-]?[13-9]){1}[0-9]{1}(?:[\s.-]?\d{2}){3}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'NL':
|
||||
// https://regex101.com/r/mX2wJ2/1
|
||||
value = $.trim(value);
|
||||
isValid = (/(^\+[0-9]{2}|^\+[0-9]{2}\(0\)|^\(\+[0-9]{2}\)\(0\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\-\s]{10}$)/).test(value);
|
||||
break;
|
||||
|
||||
case 'PK':
|
||||
// http://regex101.com/r/yH8aV9/2
|
||||
value = $.trim(value);
|
||||
isValid = (/^0?3[0-9]{2}[0-9]{7}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'RO':
|
||||
// All mobile network and land line
|
||||
// http://regexr.com/39fv1
|
||||
isValid = (/^(\+4|)?(07[0-8]{1}[0-9]{1}|02[0-9]{2}|03[0-9]{2}){1}?(\s|\.|\-)?([0-9]{3}(\s|\.|\-|)){2}$/g).test(value);
|
||||
break;
|
||||
|
||||
case 'RU':
|
||||
// http://regex101.com/r/gW7yT5/5
|
||||
isValid = (/^((8|\+7|007)[\-\.\/ ]?)?([\(\/\.]?\d{3}[\)\/\.]?[\-\.\/ ]?)?[\d\-\.\/ ]{7,10}$/g).test(value);
|
||||
break;
|
||||
|
||||
case 'SK':
|
||||
// Test: http://regexr.com/39hhl
|
||||
isValid = /^(((00)([- ]?)|\+)(420)([- ]?))?((\d{3})([- ]?)){2}(\d{3})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'TH':
|
||||
// http://regex101.com/r/vM5mZ4/2
|
||||
isValid = (/^0\(?([6|8-9]{2})*-([0-9]{3})*-([0-9]{4})$/).test(value);
|
||||
break;
|
||||
|
||||
case 'VE':
|
||||
// http://regex101.com/r/eM2yY0/6
|
||||
value = $.trim(value);
|
||||
isValid = (/^0(?:2(?:12|4[0-9]|5[1-9]|6[0-9]|7[0-8]|8[1-35-8]|9[1-5]|3[45789])|4(?:1[246]|2[46]))\d{7}$/).test(value);
|
||||
break;
|
||||
|
||||
case 'US':
|
||||
/* falls through */
|
||||
default:
|
||||
// Make sure US phone numbers have 10 digits
|
||||
// May start with 1, +1, or 1-; should discard
|
||||
// Area code may be delimited with (), & sections may be delimited with . or -
|
||||
// Test: http://regexr.com/38mqi
|
||||
isValid = (/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value);
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
valid: isValid,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].phone.country, FormValidation.I18n[locale].phone.countries[country])
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.phone;
|
||||
}));
|
||||
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* regexp validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/regexp/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/regexp", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
regexp: {
|
||||
'default': 'Please enter a value matching the pattern'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.regexp = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
regexp: 'regexp'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
var pattern = $field.attr('pattern');
|
||||
if (pattern) {
|
||||
return {
|
||||
regexp: pattern
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the element value matches given regular expression
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of the following key:
|
||||
* - regexp: The regular expression you need to check
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'regexp');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var regexp = ('string' === typeof options.regexp) ? new RegExp(options.regexp) : options.regexp;
|
||||
return regexp.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.regexp;
|
||||
}));
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* remote validator
|
||||
*/
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/remote", ["jquery", "base", "csrfToken"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
}(this, function ($, FormValidation, csrfTokenHeader) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
remote: {
|
||||
'default': ''
|
||||
}
|
||||
}
|
||||
});
|
||||
FormValidation.Validator.remote = {
|
||||
validate: function(validator, $field, options) {
|
||||
var dfd = new $.Deferred(), ajaxData = {};
|
||||
ajaxData[options.field] = $field.val();
|
||||
if ($field.val() === '')
|
||||
return true;
|
||||
var url = options.url;
|
||||
var xhr = $.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
data: ajaxData,
|
||||
method: "post"
|
||||
});
|
||||
xhr.success(function(response) {
|
||||
if (response.code == 1)
|
||||
dfd.resolve($field, 'remote',{valid:true, message:options.msg});
|
||||
dfd.resolve($field, 'remote',{valid:!response.data, message:options.msg});
|
||||
})
|
||||
.error(function(response) {
|
||||
dfd.resolve($field, 'remote', {valid: false});
|
||||
});
|
||||
return dfd;
|
||||
}
|
||||
};
|
||||
}));
|
||||
@@ -1,146 +0,0 @@
|
||||
/**
|
||||
* remote validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/remote/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/remote", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
remote: {
|
||||
'default': 'Please enter a valid value'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.remote = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
name: 'name',
|
||||
type: 'type',
|
||||
url: 'url',
|
||||
data: 'data',
|
||||
delay: 'delay'
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the timer when destroying the bootstrapValidator (using validator.destroy() method)
|
||||
*/
|
||||
destroy: function(validator, $field, options) {
|
||||
var ns = validator.getNamespace(),
|
||||
timer = $field.data(ns + '.remote.timer');
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
$field.removeData(ns + '.remote.timer');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Request a remote server to check the input value
|
||||
*
|
||||
* @param {FormValidation.Base} validator Plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - url {String|Function}
|
||||
* - type {String} [optional] Can be GET or POST (default)
|
||||
* - data {Object|Function} [optional]: By default, it will take the value
|
||||
* {
|
||||
* <fieldName>: <fieldValue>
|
||||
* }
|
||||
* - delay
|
||||
* - name {String} [optional]: Override the field name for the request.
|
||||
* - message: The invalid message
|
||||
* - headers: Additional headers
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var ns = validator.getNamespace(),
|
||||
value = validator.getFieldValue($field, 'remote'),
|
||||
dfd = new $.Deferred();
|
||||
if (value === '') {
|
||||
dfd.resolve($field, 'remote', { valid: true });
|
||||
return dfd;
|
||||
}
|
||||
|
||||
var name = $field.attr('data-' + ns + '-field'),
|
||||
data = options.data || {},
|
||||
url = options.url,
|
||||
type = options.type || 'GET',
|
||||
headers = options.headers || {};
|
||||
|
||||
// Support dynamic data
|
||||
if ('function' === typeof data) {
|
||||
data = data.call(this, validator);
|
||||
}
|
||||
|
||||
// Parse string data from HTML5 attribute
|
||||
if ('string' === typeof data) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
|
||||
// Support dynamic url
|
||||
if ('function' === typeof url) {
|
||||
url = url.call(this, validator);
|
||||
}
|
||||
|
||||
data[options.name || name] = value;
|
||||
function runCallback() {
|
||||
var xhr = $.ajax({
|
||||
type: type,
|
||||
headers: headers,
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
data: data
|
||||
});
|
||||
|
||||
xhr
|
||||
.success(function(response) {
|
||||
response.valid = response.valid === true || response.valid === 'true';
|
||||
dfd.resolve($field, 'remote', response);
|
||||
})
|
||||
.error(function(response) {
|
||||
dfd.resolve($field, 'remote', {
|
||||
valid: false
|
||||
});
|
||||
});
|
||||
|
||||
dfd.fail(function() {
|
||||
xhr.abort();
|
||||
});
|
||||
|
||||
return dfd;
|
||||
}
|
||||
|
||||
if (options.delay) {
|
||||
// Since the form might have multiple fields with the same name
|
||||
// I have to attach the timer to the field element
|
||||
if ($field.data(ns + '.remote.timer')) {
|
||||
clearTimeout($field.data(ns + '.remote.timer'));
|
||||
}
|
||||
|
||||
$field.data(ns + '.remote.timer', setTimeout(runCallback, options.delay));
|
||||
return dfd;
|
||||
} else {
|
||||
return runCallback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.remote;
|
||||
}));
|
||||
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* rtn validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/rtn/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/rtn", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
rtn: {
|
||||
'default': 'Please enter a valid RTN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.rtn = {
|
||||
/**
|
||||
* Validate a RTN (Routing transit number)
|
||||
* Examples:
|
||||
* - Valid: 021200025, 789456124
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Routing_transit_number
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'rtn');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!/^\d{9}$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var sum = 0;
|
||||
for (var i = 0; i < value.length; i += 3) {
|
||||
sum += parseInt(value.charAt(i), 10) * 3
|
||||
+ parseInt(value.charAt(i + 1), 10) * 7
|
||||
+ parseInt(value.charAt(i + 2), 10);
|
||||
}
|
||||
return (sum !== 0 && sum % 10 === 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.rtn;
|
||||
}));
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* sedol validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/sedol/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/sedol", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
sedol: {
|
||||
'default': 'Please enter a valid SEDOL number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.sedol = {
|
||||
/**
|
||||
* Validate a SEDOL (Stock Exchange Daily Official List)
|
||||
* Examples:
|
||||
* - Valid: 0263494, B0WNLY7
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/SEDOL
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'sedol');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
value = value.toUpperCase();
|
||||
if (!/^[0-9A-Z]{7}$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var sum = 0,
|
||||
weight = [1, 3, 1, 7, 3, 9, 1],
|
||||
length = value.length;
|
||||
for (var i = 0; i < length - 1; i++) {
|
||||
sum += weight[i] * parseInt(value.charAt(i), 36);
|
||||
}
|
||||
sum = (10 - sum % 10) % 10;
|
||||
return sum + '' === value.charAt(length - 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.sedol;
|
||||
}));
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* siren validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/siren/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/siren", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
siren: {
|
||||
'default': 'Please enter a valid SIREN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.siren = {
|
||||
/**
|
||||
* Check if a string is a siren number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'siren');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!/^\d{9}$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
return FormValidation.Helper.luhn(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.siren;
|
||||
}));
|
||||
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* siret validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/siret/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/siret", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
siret: {
|
||||
'default': 'Please enter a valid SIRET number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.siret = {
|
||||
/**
|
||||
* Check if a string is a siret number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'siret');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var sum = 0,
|
||||
length = value.length,
|
||||
tmp;
|
||||
for (var i = 0; i < length; i++) {
|
||||
tmp = parseInt(value.charAt(i), 10);
|
||||
if ((i % 2) === 0) {
|
||||
tmp = tmp * 2;
|
||||
if (tmp > 9) {
|
||||
tmp -= 9;
|
||||
}
|
||||
}
|
||||
sum += tmp;
|
||||
}
|
||||
return (sum % 10 === 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.siret;
|
||||
}));
|
||||
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* step validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/step/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/step", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
step: {
|
||||
'default': 'Please enter a valid step of %s'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.step = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
base: 'baseValue',
|
||||
step: 'step'
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is valid step one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Can consist of the following keys:
|
||||
* - baseValue: The base value
|
||||
* - step: The step
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'step');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
options = $.extend({}, { baseValue: 0, step: 1 }, options);
|
||||
value = parseFloat(value);
|
||||
if (!$.isNumeric(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var round = function(x, precision) {
|
||||
var m = Math.pow(10, precision);
|
||||
x = x * m;
|
||||
var sign = (x > 0) | -(x < 0),
|
||||
isHalf = (x % 1 === 0.5 * sign);
|
||||
if (isHalf) {
|
||||
return (Math.floor(x) + (sign > 0)) / m;
|
||||
} else {
|
||||
return Math.round(x) / m;
|
||||
}
|
||||
},
|
||||
floatMod = function(x, y) {
|
||||
if (y === 0.0) {
|
||||
return 1.0;
|
||||
}
|
||||
var dotX = (x + '').split('.'),
|
||||
dotY = (y + '').split('.'),
|
||||
precision = ((dotX.length === 1) ? 0 : dotX[1].length) + ((dotY.length === 1) ? 0 : dotY[1].length);
|
||||
return round(x - y * Math.floor(x / y), precision);
|
||||
};
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
mod = floatMod(value - options.baseValue, options.step);
|
||||
return {
|
||||
valid: mod === 0.0 || mod === options.step,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].step['default'], [options.step])
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.step;
|
||||
}));
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* stringCase validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/stringCase/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/stringCase", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
stringCase: {
|
||||
'default': 'Please enter only lowercase characters',
|
||||
upper: 'Please enter only uppercase characters'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.stringCase = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
'case': 'case'
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if a string is a lower or upper case one
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* - case: Can be 'lower' (default) or 'upper'
|
||||
* @returns {Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'stringCase');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
stringCase = (options['case'] || 'lower').toLowerCase();
|
||||
return {
|
||||
valid: ('upper' === stringCase) ? value === value.toUpperCase() : value === value.toLowerCase(),
|
||||
message: options.message || (('upper' === stringCase) ? FormValidation.I18n[locale].stringCase.upper : FormValidation.I18n[locale].stringCase['default'])
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.stringCase;
|
||||
}));
|
||||
@@ -1,140 +0,0 @@
|
||||
/**
|
||||
* stringLength validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/stringLength/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/stringLength", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
stringLength: {
|
||||
'default': 'Please enter a value with valid length',
|
||||
less: 'Please enter less than %s characters',
|
||||
more: 'Please enter more than %s characters',
|
||||
between: 'Please enter value between %s and %s characters long'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.stringLength = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
min: 'min',
|
||||
max: 'max',
|
||||
trim: 'trim',
|
||||
utf8bytes: 'utf8Bytes'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
var options = {},
|
||||
maxLength = $field.attr('maxlength'),
|
||||
minLength = $field.attr('minlength');
|
||||
if (maxLength) {
|
||||
options.max = parseInt(maxLength, 10);
|
||||
}
|
||||
if (minLength) {
|
||||
options.min = parseInt(minLength, 10);
|
||||
}
|
||||
|
||||
return $.isEmptyObject(options) ? false : options;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the length of element value is less or more than given number
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consists of following keys:
|
||||
* - min
|
||||
* - max
|
||||
* At least one of two keys is required
|
||||
* The min, max keys define the number which the field value compares to. min, max can be
|
||||
* - A number
|
||||
* - Name of field which its value defines the number
|
||||
* - Name of callback function that returns the number
|
||||
* - A callback function that returns the number
|
||||
*
|
||||
* - message: The invalid message
|
||||
* - trim: Indicate the length will be calculated after trimming the value or not. It is false, by default
|
||||
* - utf8bytes: Evaluate string length in UTF-8 bytes, default to false
|
||||
* @returns {Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'stringLength');
|
||||
if (options.trim === true || options.trim === 'true') {
|
||||
value = $.trim(value);
|
||||
}
|
||||
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
|
||||
max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
|
||||
// Credit to http://stackoverflow.com/a/23329386 (@lovasoa) for UTF-8 byte length code
|
||||
utf8Length = function(str) {
|
||||
var s = str.length;
|
||||
for (var i = str.length - 1; i >= 0; i--) {
|
||||
var code = str.charCodeAt(i);
|
||||
if (code > 0x7f && code <= 0x7ff) {
|
||||
s++;
|
||||
} else if (code > 0x7ff && code <= 0xffff) {
|
||||
s += 2;
|
||||
}
|
||||
if (code >= 0xDC00 && code <= 0xDFFF) {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
},
|
||||
length = options.utf8Bytes ? utf8Length(value) : value.length,
|
||||
isValid = true,
|
||||
message = options.message || FormValidation.I18n[locale].stringLength['default'];
|
||||
|
||||
if ((min && length < parseInt(min, 10)) || (max && length > parseInt(max, 10))) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case (!!min && !!max):
|
||||
message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.between, [parseInt(min, 10), parseInt(max, 10)]);
|
||||
break;
|
||||
|
||||
case (!!min):
|
||||
message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.more, parseInt(min, 10));
|
||||
break;
|
||||
|
||||
case (!!max):
|
||||
message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.less, parseInt(max, 10));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
valid: isValid,
|
||||
message: message
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.stringLength;
|
||||
}));
|
||||
@@ -1,144 +0,0 @@
|
||||
/**
|
||||
* uri validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/uri/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/uri", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
uri: {
|
||||
'default': 'Please enter a valid URI'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.uri = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
allowlocal: 'allowLocal',
|
||||
allowemptyprotocol: 'allowEmptyProtocol',
|
||||
protocol: 'protocol'
|
||||
},
|
||||
|
||||
enableByHtml5: function($field) {
|
||||
return ('url' === $field.attr('type'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the input value is a valid URL
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options
|
||||
* - message: The error message
|
||||
* - allowLocal: Allow the private and local network IP. Default to false
|
||||
* - allowEmptyProtocol: Allow the URI without protocol. Default to false
|
||||
* - protocol: The protocols, separated by a comma. Default to "http, https, ftp"
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'uri');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Credit to https://gist.github.com/dperini/729294
|
||||
//
|
||||
// Regular Expression for URL validation
|
||||
//
|
||||
// Author: Diego Perini
|
||||
// Updated: 2010/12/05
|
||||
//
|
||||
// the regular expression composed & commented
|
||||
// could be easily tweaked for RFC compliance,
|
||||
// it was expressly modified to fit & satisfy
|
||||
// these test for an URL shortener:
|
||||
//
|
||||
// http://mathiasbynens.be/demo/url-regex
|
||||
//
|
||||
// Notes on possible differences from a standard/generic validation:
|
||||
//
|
||||
// - utf-8 char class take in consideration the full Unicode range
|
||||
// - TLDs are mandatory unless `allowLocal` is true
|
||||
// - protocols have been restricted to ftp, http and https only as requested
|
||||
//
|
||||
// Changes:
|
||||
//
|
||||
// - IP address dotted notation validation, range: 1.0.0.0 - 223.255.255.255
|
||||
// first and last IP address of each class is considered invalid
|
||||
// (since they are broadcast/network addresses)
|
||||
//
|
||||
// - Added exclusion of private, reserved and/or local networks ranges
|
||||
// unless `allowLocal` is true
|
||||
//
|
||||
// - Added possibility of choosing a custom protocol
|
||||
//
|
||||
// - Add option to validate without protocol
|
||||
//
|
||||
var allowLocal = options.allowLocal === true || options.allowLocal === 'true',
|
||||
allowEmptyProtocol = options.allowEmptyProtocol === true || options.allowEmptyProtocol === 'true',
|
||||
protocol = (options.protocol || 'http, https, ftp').split(',').join('|').replace(/\s/g, ''),
|
||||
urlExp = new RegExp(
|
||||
"^" +
|
||||
// protocol identifier
|
||||
"(?:(?:" + protocol + ")://)" +
|
||||
// allow empty protocol
|
||||
(allowEmptyProtocol ? '?' : '') +
|
||||
// user:pass authentication
|
||||
"(?:\\S+(?::\\S*)?@)?" +
|
||||
"(?:" +
|
||||
// IP address exclusion
|
||||
// private & local networks
|
||||
(allowLocal
|
||||
? ''
|
||||
: ("(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
|
||||
"(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
|
||||
"(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})")) +
|
||||
// IP address dotted notation octets
|
||||
// excludes loopback network 0.0.0.0
|
||||
// excludes reserved space >= 224.0.0.0
|
||||
// excludes network & broadcast addresses
|
||||
// (first & last IP address of each class)
|
||||
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
|
||||
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
|
||||
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
|
||||
"|" +
|
||||
// host name
|
||||
"(?:(?:[a-z\\u00a1-\\uffff0-9]-?)*[a-z\\u00a1-\\uffff0-9]+)" +
|
||||
// domain name
|
||||
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-?)*[a-z\\u00a1-\\uffff0-9])*" +
|
||||
// TLD identifier
|
||||
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
|
||||
// Allow intranet sites (no TLD) if `allowLocal` is true
|
||||
(allowLocal ? '?' : '') +
|
||||
")" +
|
||||
// port number
|
||||
"(?::\\d{2,5})?" +
|
||||
// resource path
|
||||
"(?:/[^\\s]*)?" +
|
||||
"$", "i"
|
||||
);
|
||||
|
||||
return urlExp.test(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.uri;
|
||||
}));
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* uuid validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/uuid/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/uuid", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
uuid: {
|
||||
'default': 'Please enter a valid UUID number',
|
||||
version: 'Please enter a valid UUID version %s number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.uuid = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
version: 'version'
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if and only if the input value is a valid UUID string
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Universally_unique_identifier
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* - version: Can be 3, 4, 5, null
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'uuid');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// See the format at http://en.wikipedia.org/wiki/Universally_unique_identifier#Variants_and_versions
|
||||
var locale = validator.getLocale(),
|
||||
patterns = {
|
||||
'3': /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
|
||||
'4': /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
||||
'5': /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
||||
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
|
||||
},
|
||||
version = options.version ? (options.version + '') : 'all';
|
||||
return {
|
||||
valid: (null === patterns[version]) ? true : patterns[version].test(value),
|
||||
message: options.version
|
||||
? FormValidation.Helper.format(options.message || FormValidation.I18n[locale].uuid.version, options.version)
|
||||
: (options.message || FormValidation.I18n[locale].uuid['default'])
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.uuid;
|
||||
}));
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* vin validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/vin/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/vin", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
vin: {
|
||||
'default': 'Please enter a valid VIN number'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.vin = {
|
||||
/**
|
||||
* Validate an US VIN (Vehicle Identification Number)
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'vin');
|
||||
if (value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't accept I, O, Q characters
|
||||
if (!/^[a-hj-npr-z0-9]{8}[0-9xX][a-hj-npr-z0-9]{8}$/i.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = value.toUpperCase();
|
||||
var chars = {
|
||||
A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8,
|
||||
J: 1, K: 2, L: 3, M: 4, N: 5, P: 7, R: 9,
|
||||
S: 2, T: 3, U: 4, V: 5, W: 6, X: 7, Y: 8, Z: 9,
|
||||
'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '0': 0
|
||||
},
|
||||
weights = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2],
|
||||
sum = 0,
|
||||
length = value.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
sum += chars[value.charAt(i) + ''] * weights[i];
|
||||
}
|
||||
|
||||
var reminder = sum % 11;
|
||||
if (reminder === 10) {
|
||||
reminder = 'X';
|
||||
}
|
||||
|
||||
return (reminder + '') === value.charAt(8);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.vin;
|
||||
}));
|
||||
@@ -1,269 +0,0 @@
|
||||
/**
|
||||
* zipCode validator
|
||||
*
|
||||
* @link http://formvalidation.io/validators/zipCode/
|
||||
* @author https://twitter.com/nghuuphuoc
|
||||
* @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
|
||||
* @license http://formvalidation.io/license/
|
||||
*/
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// AMD module is defined
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("validator/zipCode", ["jquery", "base"], factory);
|
||||
} else {
|
||||
// planted over the root!
|
||||
factory(root.jQuery, root.FormValidation);
|
||||
}
|
||||
|
||||
}(this, function ($, FormValidation) {
|
||||
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
|
||||
'en_US': {
|
||||
zipCode: {
|
||||
'default': 'Please enter a valid postal code',
|
||||
country: 'Please enter a valid postal code in %s',
|
||||
countries: {
|
||||
AT: 'Austria',
|
||||
BG: 'Bulgaria',
|
||||
BR: 'Brazil',
|
||||
CA: 'Canada',
|
||||
CH: 'Switzerland',
|
||||
CZ: 'Czech Republic',
|
||||
DE: 'Germany',
|
||||
DK: 'Denmark',
|
||||
ES: 'Spain',
|
||||
FR: 'France',
|
||||
GB: 'United Kingdom',
|
||||
IE: 'Ireland',
|
||||
IN: 'India',
|
||||
IT: 'Italy',
|
||||
MA: 'Morocco',
|
||||
NL: 'Netherlands',
|
||||
PT: 'Portugal',
|
||||
RO: 'Romania',
|
||||
RU: 'Russia',
|
||||
SE: 'Sweden',
|
||||
SG: 'Singapore',
|
||||
SK: 'Slovakia',
|
||||
US: 'USA'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FormValidation.Validator.zipCode = {
|
||||
html5Attributes: {
|
||||
message: 'message',
|
||||
country: 'country'
|
||||
},
|
||||
|
||||
COUNTRY_CODES: ['AT', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'ES', 'FR', 'GB', 'IE', 'IN', 'IT', 'MA', 'NL', 'PT', 'RO', 'RU', 'SE', 'SG', 'SK', 'US'],
|
||||
|
||||
/**
|
||||
* Return true if and only if the input value is a valid country zip code
|
||||
*
|
||||
* @param {FormValidation.Base} validator The validator plugin instance
|
||||
* @param {jQuery} $field Field element
|
||||
* @param {Object} options Consist of key:
|
||||
* - message: The invalid message
|
||||
* - country: The country
|
||||
*
|
||||
* The country can be defined by:
|
||||
* - An ISO 3166 country code
|
||||
* - Name of field which its value defines the country code
|
||||
* - Name of callback function that returns the country code
|
||||
* - A callback function that returns the country code
|
||||
*
|
||||
* callback: function(value, validator, $field) {
|
||||
* // value is the value of field
|
||||
* // validator is the BootstrapValidator instance
|
||||
* // $field is jQuery element representing the field
|
||||
* }
|
||||
*
|
||||
* @returns {Boolean|Object}
|
||||
*/
|
||||
validate: function(validator, $field, options) {
|
||||
var value = validator.getFieldValue($field, 'zipCode');
|
||||
if (value === '' || !options.country) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var locale = validator.getLocale(),
|
||||
country = options.country;
|
||||
if (typeof country !== 'string' || $.inArray(country, this.COUNTRY_CODES) === -1) {
|
||||
// Try to determine the country
|
||||
country = validator.getDynamicOption($field, country);
|
||||
}
|
||||
|
||||
if (!country || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var isValid = false;
|
||||
country = country.toUpperCase();
|
||||
switch (country) {
|
||||
// http://en.wikipedia.org/wiki/List_of_postal_codes_in_Austria
|
||||
case 'AT':
|
||||
isValid = /^([1-9]{1})(\d{3})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'BG':
|
||||
isValid = /^([1-9]{1}[0-9]{3})$/.test($.trim(value));
|
||||
break;
|
||||
|
||||
case 'BR':
|
||||
isValid = /^(\d{2})([\.]?)(\d{3})([\-]?)(\d{3})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'CA':
|
||||
isValid = /^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(value);
|
||||
break;
|
||||
|
||||
case 'CH':
|
||||
isValid = /^([1-9]{1})(\d{3})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'CZ':
|
||||
// Test: http://regexr.com/39hhr
|
||||
isValid = /^(\d{3})([ ]?)(\d{2})$/.test(value);
|
||||
break;
|
||||
|
||||
// http://stackoverflow.com/questions/7926687/regular-expression-german-zip-codes
|
||||
case 'DE':
|
||||
isValid = /^(?!01000|99999)(0[1-9]\d{3}|[1-9]\d{4})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'DK':
|
||||
isValid = /^(DK(-|\s)?)?\d{4}$/i.test(value);
|
||||
break;
|
||||
|
||||
// Zip codes in Spain go from 01XXX to 52XXX.
|
||||
// Test: http://refiddle.com/1ufo
|
||||
case 'ES':
|
||||
isValid = /^(?:0[1-9]|[1-4][0-9]|5[0-2])\d{3}$/.test(value);
|
||||
break;
|
||||
|
||||
// http://en.wikipedia.org/wiki/Postal_codes_in_France
|
||||
case 'FR':
|
||||
isValid = /^[0-9]{5}$/i.test(value);
|
||||
break;
|
||||
|
||||
case 'GB':
|
||||
isValid = this._gb(value);
|
||||
break;
|
||||
|
||||
// Indian PIN (Postal Index Number) validation
|
||||
// http://en.wikipedia.org/wiki/Postal_Index_Number
|
||||
// Test: http://regex101.com/r/kV0vH3/1
|
||||
case 'IN':
|
||||
isValid = /^\d{3}\s?\d{3}$/.test(value);
|
||||
break;
|
||||
|
||||
// http://www.eircode.ie/docs/default-source/Common/prepare-your-business-for-eircode---published-v2.pdf?sfvrsn=2
|
||||
// Test: http://refiddle.com/1kpl
|
||||
case 'IE':
|
||||
isValid = /^(D6W|[ACDEFHKNPRTVWXY]\d{2})\s[0-9ACDEFHKNPRTVWXY]{4}$/.test(value);
|
||||
break;
|
||||
|
||||
// http://en.wikipedia.org/wiki/List_of_postal_codes_in_Italy
|
||||
case 'IT':
|
||||
isValid = /^(I-|IT-)?\d{5}$/i.test(value);
|
||||
break;
|
||||
|
||||
// http://en.wikipedia.org/wiki/List_of_postal_codes_in_Morocco
|
||||
case 'MA':
|
||||
isValid = /^[1-9][0-9]{4}$/i.test(value);
|
||||
break;
|
||||
|
||||
// http://en.wikipedia.org/wiki/Postal_codes_in_the_Netherlands
|
||||
case 'NL':
|
||||
isValid = /^[1-9][0-9]{3} ?(?!sa|sd|ss)[a-z]{2}$/i.test(value);
|
||||
break;
|
||||
|
||||
// Test: http://refiddle.com/1l2t
|
||||
case 'PT':
|
||||
isValid = /^[1-9]\d{3}-\d{3}$/.test(value);
|
||||
break;
|
||||
|
||||
case 'RO':
|
||||
isValid = /^(0[1-8]{1}|[1-9]{1}[0-5]{1})?[0-9]{4}$/i.test(value);
|
||||
break;
|
||||
|
||||
case 'RU':
|
||||
isValid = /^[0-9]{6}$/i.test(value);
|
||||
break;
|
||||
|
||||
case 'SE':
|
||||
isValid = /^(S-)?\d{3}\s?\d{2}$/i.test(value);
|
||||
break;
|
||||
|
||||
case 'SG':
|
||||
isValid = /^([0][1-9]|[1-6][0-9]|[7]([0-3]|[5-9])|[8][0-2])(\d{4})$/i.test(value);
|
||||
break;
|
||||
|
||||
case 'SK':
|
||||
// Test: http://regexr.com/39hhr
|
||||
isValid = /^(\d{3})([ ]?)(\d{2})$/.test(value);
|
||||
break;
|
||||
|
||||
case 'US':
|
||||
/* falls through */
|
||||
default:
|
||||
isValid = /^\d{4,5}([\-]?\d{4})?$/.test(value);
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
valid: isValid,
|
||||
message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].zipCode.country, FormValidation.I18n[locale].zipCode.countries[country])
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate United Kingdom postcode
|
||||
* Examples:
|
||||
* - Standard: EC1A 1BB, W1A 1HQ, M1 1AA, B33 8TH, CR2 6XH, DN55 1PT
|
||||
* - Special cases:
|
||||
* AI-2640, ASCN 1ZZ, GIR 0AA
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
|
||||
* @param {String} value The postcode
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
_gb: function(value) {
|
||||
var firstChar = '[ABCDEFGHIJKLMNOPRSTUWYZ]', // Does not accept QVX
|
||||
secondChar = '[ABCDEFGHKLMNOPQRSTUVWXY]', // Does not accept IJZ
|
||||
thirdChar = '[ABCDEFGHJKPMNRSTUVWXY]',
|
||||
fourthChar = '[ABEHMNPRVWXY]',
|
||||
fifthChar = '[ABDEFGHJLNPQRSTUWXYZ]',
|
||||
regexps = [
|
||||
// AN NAA, ANN NAA, AAN NAA, AANN NAA format
|
||||
new RegExp('^(' + firstChar + '{1}' + secondChar + '?[0-9]{1,2})(\\s*)([0-9]{1}' + fifthChar + '{2})$', 'i'),
|
||||
// ANA NAA
|
||||
new RegExp('^(' + firstChar + '{1}[0-9]{1}' + thirdChar + '{1})(\\s*)([0-9]{1}' + fifthChar + '{2})$', 'i'),
|
||||
// AANA NAA
|
||||
new RegExp('^(' + firstChar + '{1}' + secondChar + '{1}?[0-9]{1}' + fourthChar + '{1})(\\s*)([0-9]{1}' + fifthChar + '{2})$', 'i'),
|
||||
|
||||
new RegExp('^(BF1)(\\s*)([0-6]{1}[ABDEFGHJLNPQRST]{1}[ABDEFGHJLNPQRSTUWZYZ]{1})$', 'i'), // BFPO postcodes
|
||||
/^(GIR)(\s*)(0AA)$/i, // Special postcode GIR 0AA
|
||||
/^(BFPO)(\s*)([0-9]{1,4})$/i, // Standard BFPO numbers
|
||||
/^(BFPO)(\s*)(c\/o\s*[0-9]{1,3})$/i, // c/o BFPO numbers
|
||||
/^([A-Z]{4})(\s*)(1ZZ)$/i, // Overseas Territories
|
||||
/^(AI-2640)$/i // Anguilla
|
||||
];
|
||||
for (var i = 0; i < regexps.length; i++) {
|
||||
if (regexps[i].test(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return FormValidation.Validator.zipCode;
|
||||
}));
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^Line truncated
|
||||
|
||||
return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var
Line truncated
|
||||
return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$a||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);g>f;f++)if(d=db[f].call(j,a,k,j.opts))return d;return m.map(k,hb,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kb,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],eb[cLine truncated
|
||||
//# sourceMappingURL=jquery.min.map
|
||||
@@ -1 +0,0 @@
|
||||
!function(a){"function"==typeof define&&define.amd?define(["../../jquery.min.js"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){function b(b,d,e){var d={content:{message:"object"==typeof d?d.message:d,title:d.title?d.title:"",icon:d.icon?d.icon:"",url:d.url?d.url:"#",target:d.target?d.target:"-"}};e=a.extend(!0,{},d,e),this.settings=a.extend(!0,{},c,e),this._defaults=c,"-"==this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),this.init()}var c={element:"body",position:null,type:"info",allow_dismiss:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:'<div data-notify="container" class="col-xs-11 col-sm-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'};String.format=function(){for(var a=arguments[0],b=1;b<arguments.length;b++)a=a.replace(RegExp("\\{"+(b-1)+"\\}","gm"),arguments[b]);return a},a.extend(b.prototype,{init:function(){var a=this;this.buildNotify(),this.settings.content.icon&&this.setIcon(),"#"!=this.settings.content.url&&this.styleURL(),this.styleDismiss(),this.placement(),this.bind(),this.notify={$ele:this.$ele,update:function(b,c){var d={};"string"==typeof b?d[b]=c:d=b;for(var b in d)switch(b){case"type":this.$ele.removeClass("alert-"+a.settings.type),this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass("progress-bar-"+a.settings.type),a.settings.type=d[b],this.$ele.addClass("alert-"+d[b]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+d[b]);break;case"icon":var e=this.$ele.find('[data-notify="icon"]');"class"==a.settings.icon_type.toLowerCase()?e.removeClass(a.settings.content.icon).addClass(d[b]):(e.is("img")||e.find("img"),e.attr("src",d[b]));break;case"progress":var f=a.settings.delay-a.settings.delay*(d[b]/100);this.$ele.data("notify-delay",f),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",d[b]).css("width",d[b]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",d[b]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",d[b]);break;default:this.$ele.find('[data-notify="'+b+'"]').html(d[b])}var g=this.$ele.outerHeight()+parseInt(a.settings.spacing)+parseInt(a.settings.offset.y);a.reposition(g)},close:function(){a.close()}}},buildNotify:function(){var b=this.settings.content;this.$ele=a(String.format(this.settings.template,this.settings.type,b.title,b.message,b.url,b.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay<=0&&!this.settings.showProgressbar||!this.settings.showProgressbar)&&this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"==this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('<img src="'+this.settings.content.icon+'" alt="Notify Icon" />')},styleDismiss:function(){this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:"0px",position:"absolute",top:"0px",width:"100%",zIndex:this.settings.z_index+1})},placement:function(){var b=this,c=this.settings.offset.y,d={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},e=!1,f=this.settings;switch(a('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){return c=Math.max(c,parseInt(a(this).css(f.placement.froLine truncated
|
||||
@@ -1,15 +0,0 @@
|
||||
define("formValidation",
|
||||
[ 'base',
|
||||
'helper',
|
||||
'framework/bootstrap',
|
||||
'language/zh_CN',
|
||||
'validator/notEmpty',
|
||||
'validator/stringLength',
|
||||
'validator/date',
|
||||
'validator/integer',
|
||||
'validator/between',
|
||||
'validator/confirm',
|
||||
'validator/remote',
|
||||
'validator/emailAddress'],
|
||||
function () {
|
||||
});
|
||||
Reference in new issue
Block a user