";if(!a("#floatCorner_"+g).size()){a("body").append(a(h))}this.corner=a("#floatCorner_"+g);return this},targetHold:function(){if(this.s.hoverHold){var d=parseInt(this.s.hideDelay,10)||200;if(this.target){this.target.hover(function(){c.flagDisplay=true},function(){if(c.timerHold){clearTimeout(c.timerHold)}c.flagDisplay=false;c.targetHold()})}c.timerHold=setTimeout(function(){c.displayDetect.call(c)},d)}else{this.displayDetect()}return this},loading:function(){this.target=a('');this.targetShow();this.target.removeData("width").removeData("height");return this},displayDetect:function(){if(!this.flagDisplay&&this.display){this.targetHide();this.timerHold=null}return this},targetShow:function(){c.cornerClear();this.display=true;this.container().setWidth().position();this.target.show();if(a.isFunction(this.s.showCall)){this.s.showCall.call(this.trigger,this.target)}return this},targetHide:function(){this.display=false;this.targetClear();this.cornerClear();if(a.isFunction(this.s.hideCall)){this.s.hideCall.call(this.trigger)}this.target=null;this.trigger=null;this.s={};this.targetProtect=false;return this},targetClear:function(){if(this.target){if(this.target.data("width")){this.target.removeData("width").removeData("height")}if(this.targetProtect){this.target.children().hide().appendTo(a("body"))}this.target.unbind().hide()}},cornerClear:function(){if(this.corner){this.corner.remove()}},target:null,trigger:null,s:{},cacheData:{},targetProtect:false};a.powerFloat={};a.powerFloat.hide=function(){c.targetHide()};var b={width:"auto",offsets:{x:0,y:0},zIndex:999,eventType:"hover",showDelay:0,hideDelay:0,hoverHold:true,hoverFollow:false,targetMode:"common",target:null,targetAttr:"rel",container:null,reverseSharp:false,position:"4-1",edgeAdjust:true,showCall:a.noop,hideCall:a.noop}})(jQuery);
\ No newline at end of file
diff --git a/WebRoot/js/jquery-validation/jquery.validate.css b/WebRoot/js/jquery-validation/jquery.validate.css
new file mode 100644
index 0000000..9500c4a
--- /dev/null
+++ b/WebRoot/js/jquery-validation/jquery.validate.css
@@ -0,0 +1,13 @@
+label.error {
+ width: 10em;
+ float: none;
+ color: red;
+ padding-left: .5em;
+ vertical-align: top;
+ height:29px;
+ line-height:29px;
+}
+
+p {
+ clear: both;
+}
diff --git a/WebRoot/js/jquery-validation/jquery.validate.min.js b/WebRoot/js/jquery-validation/jquery.validate.min.js
new file mode 100644
index 0000000..edd6452
--- /dev/null
+++ b/WebRoot/js/jquery-validation/jquery.validate.min.js
@@ -0,0 +1,51 @@
+/**
+ * jQuery Validation Plugin 1.9.0
+ *
+ * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
+ * http://docs.jquery.com/Plugins/Validation
+ *
+ * Copyright (c) 2006 - 2011 Jörn Zaefferer
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ */
+(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;this.attr("novalidate","novalidate");b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){a=this.find("input, button");a.filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&a.filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("").attr("name",
+b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
+else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
+return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
+b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
+validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
+onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
+a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
+minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator"),g="on"+e.type.replace(/^validate/,
+"");f.settings[g]&&f.settings[g].call(f,this[0],e)}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=
+this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",a).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",
+a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=
+a=this.validationTargetFor(this.clean(a));this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?
+this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.lastElement=null;this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==
+0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&
+a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},
+prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.validationTargetFor(this.clean(a));var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+
+a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+a.name+"")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=
+d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);
+if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass(this.settings.validClass).addClass(this.settings.errorClass);
+d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=
+this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];return a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,
+e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,
+c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=
+false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,
+a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e;if(e=d==="required"&&typeof c.fn.prop==="function"?a.prop(d):a.attr(d))b[d]=e;else if(a[0].getAttribute("type")===d)b[d]=true}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};
+var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?
+e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;
+return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,
+b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,
+mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,
+b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)},
+url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
+date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 -]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
+0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
+(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
+(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
+b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);
diff --git a/WebRoot/js/jquery-validation/messages_cn.js b/WebRoot/js/jquery-validation/messages_cn.js
new file mode 100644
index 0000000..814cc38
--- /dev/null
+++ b/WebRoot/js/jquery-validation/messages_cn.js
@@ -0,0 +1,23 @@
+/*
+ * Translated default messages for the jQuery validation plugin.
+ * Locale: CN
+ */
+jQuery.extend(jQuery.validator.messages, {
+ required: "必选字段",
+ remote: "请修正该字段",
+ email: "请输入正确格式的电子邮件",
+ url: "请输入合法的网址",
+ date: "请输入合法的日期",
+ dateISO: "请输入合法的日期 (ISO).",
+ number: "请输入合法的数字",
+ digits: "只能输入整数",
+ creditcard: "请输入合法的信用卡号",
+ equalTo: "请再次输入相同的值",
+ accept: "请输入拥有合法后缀名的字符串",
+ maxlength: jQuery.validator.format("请输入一个长度最多是 {1} 的字符串"),
+ minlength: jQuery.validator.format("请输入一个长度最少是 {0} 的字符串"),
+ rangelength: jQuery.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),
+ range: jQuery.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
+ max: jQuery.validator.format("请输入一个最大为 {0} 的值"),
+ min: jQuery.validator.format("请输入一个最小为 {0} 的值")
+});
\ No newline at end of file
diff --git a/WebRoot/js/jquery.validationEngine-zh_CN.js b/WebRoot/js/jquery.validationEngine-zh_CN.js
deleted file mode 100644
index f3f0c34..0000000
--- a/WebRoot/js/jquery.validationEngine-zh_CN.js
+++ /dev/null
@@ -1,177 +0,0 @@
-(function($){
- $.fn.validationEngineLanguage = function(){
- };
- $.validationEngineLanguage = {
- newLang: function(){
- $.validationEngineLanguage.allRules = {
- "required": { // Add your regex rules here, you can take telephone as an example
- "regex": "none",
- "alertText": "* 此处不可空白",
- "alertTextCheckboxMultiple": "* 请选择一个项目",
- "alertTextCheckboxe": "* 您必须钩选此栏",
- "alertTextDateRange": "* 日期范围不可空白"
- },
- "requiredInFunction": {
- "func": function(field, rules, i, options){
- return (field.val() == "test") ? true : false;
- },
- "alertText": "* Field must equal test"
- },
- "dateRange": {
- "regex": "none",
- "alertText": "* 无效的 ",
- "alertText2": " 日期范围"
- },
- "dateTimeRange": {
- "regex": "none",
- "alertText": "* 无效的 ",
- "alertText2": " 时间范围"
- },
- "minSize": {
- "regex": "none",
- "alertText": "* 最少 ",
- "alertText2": " 个字符"
- },
- "maxSize": {
- "regex": "none",
- "alertText": "* 最多 ",
- "alertText2": " 个字符"
- },
- "groupRequired": {
- "regex": "none",
- "alertText": "* 你必需选填其中一个栏位"
- },
- "min": {
- "regex": "none",
- "alertText": "* 最小值為 "
- },
- "max": {
- "regex": "none",
- "alertText": "* 最大值为 "
- },
- "past": {
- "regex": "none",
- "alertText": "* 日期必需早于 "
- },
- "future": {
- "regex": "none",
- "alertText": "* 日期必需晚于 "
- },
- "maxCheckbox": {
- "regex": "none",
- "alertText": "* 最多选取 ",
- "alertText2": " 个项目"
- },
- "minCheckbox": {
- "regex": "none",
- "alertText": "* 请选择 ",
- "alertText2": " 个项目"
- },
- "equals": {
- "regex": "none",
- "alertText": "* 请输入与上面相同的密码"
- },
- "creditCard": {
- "regex": "none",
- "alertText": "* 无效的信用卡号码"
- },
- "phone": {
- // credit: jquery.h5validate.js / orefalo
- "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
- "alertText": "* 无效的电话号码"
- },
- "email": {
- // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
- "regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
- "alertText": "* 邮件地址无效"
- },
- "integer": {
- "regex": /^[\-\+]?\d+$/,
- "alertText": "* 不是有效的整数"
- },
- "number": {
- // Number, including positive, negative, and floating decimal. credit: orefalo
- "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/,
- "alertText": "* 无效的数字"
- },
- "date": {
- "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
- "alertText": "* 无效的日期,格式必需为 YYYY-MM-DD"
- },
- "ipv4": {
- "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
- "alertText": "* 无效的 IP 地址"
- },
- "url": {
- "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
- "alertText": "* Invalid URL"
- },
- "onlyNumberSp": {
- "regex": /^[0-9\ ]+$/,
- "alertText": "* 只能填数字"
- },
- "onlyLetterSp": {
- "regex": /^[a-zA-Z\ \']+$/,
- "alertText": "* 只接受英文字母大小写"
- },
- "onlyLetterNumber": {
- "regex": /^[0-9a-zA-Z]+$/,
- "alertText": "* 不接受特殊字符"
- },
- // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
- "ajaxUserCall": {
- "url": "ajaxValidateFieldUser",
- // you may want to pass extra data on the ajax call
- "extraData": "name=eric",
- "alertText": "* 此名称已被其他人使用",
- "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
- },
- "ajaxUserCallPhp": {
- "url": "phpajax/ajaxValidateFieldUser.php",
- // you may want to pass extra data on the ajax call
- "extraData": "name=eric",
- // if you provide an "alertTextOk", it will show as a green prompt when the field validates
- "alertTextOk": "* 此帐号名称可以使用",
- "alertText": "* 此名称已被其他人使用",
- "alertTextLoad": "* 正在确认帐号名称是否有其他人使用,请稍等。"
- },
- "ajaxNameCall": {
- // remote json service location
- "url": "ajaxValidateFieldName",
- // error
- "alertText": "* 此名称可以使用",
- // if you provide an "alertTextOk", it will show as a green prompt when the field validates
- "alertTextOk": "* 此名称已被其他人使用",
- // speaks by itself
- "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
- },
- "ajaxNameCallPhp": {
- // remote json service location
- "url": "phpajax/ajaxValidateFieldName.php",
- // error
- "alertText": "* 此名称已被其他人使用",
- // speaks by itself
- "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
- },
- "validate2fields": {
- "alertText": "* 请输入 HELLO"
- },
- //tls warning:homegrown not fielded
- "dateFormat":{
- "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
- "alertText": "* 无效的日期格式"
- },
- //tls warning:homegrown not fielded
- "dateTimeFormat": {
- "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
- "alertText": "* 无效的日期或时间格式",
- "alertText2": "可接受的格式: ",
- "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM 或 ",
- "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
- }
- };
-
- }
- };
- $.validationEngineLanguage.newLang();
-})(jQuery);
diff --git a/WebRoot/js/jquery.validationEngine.js b/WebRoot/js/jquery.validationEngine.js
deleted file mode 100644
index b3b1caf..0000000
--- a/WebRoot/js/jquery.validationEngine.js
+++ /dev/null
@@ -1,2066 +0,0 @@
-/*
- * Inline Form Validation Engine 2.6.2, jQuery plugin
- *
- * Copyright(c) 2010, Cedric Dugas
- * http://www.position-absolute.com
- *
- * 2.0 Rewrite by Olivier Refalo
- * http://www.crionics.com
- *
- * Form validation engine allowing custom regex rules to be added.
- * Licensed under the MIT License
- */
- (function($) {
-
- "use strict";
-
- var methods = {
-
- /**
- * Kind of the constructor, called before any action
- * @param {Map} user options
- */
- init: function(options) {
- var form = this;
- if (!form.data('jqv') || form.data('jqv') == null ) {
- options = methods._saveOptions(form, options);
- // bind all formError elements to close on click
- $(document).on("click", ".formError", function() {
- $(this).fadeOut(150, function() {
- // remove prompt once invisible
- $(this).parent('.formErrorOuter').remove();
- $(this).remove();
- });
- });
- }
- return this;
- },
- /**
- * Attachs jQuery.validationEngine to form.submit and field.blur events
- * Takes an optional params: a list of options
- * ie. jQuery("#formID1").validationEngine('attach', {promptPosition : "centerRight"});
- */
- attach: function(userOptions) {
-
- var form = this;
- var options;
-
- if(userOptions)
- options = methods._saveOptions(form, userOptions);
- else
- options = form.data('jqv');
-
- options.validateAttribute = (form.find("[data-validation-engine*=validate]").length) ? "data-validation-engine" : "class";
- if (options.binded) {
-
- // delegate fields
- form.on(options.validationEventTrigger, "["+options.validateAttribute+"*=validate]:not([type=checkbox]):not([type=radio]):not(.datepicker)", methods._onFieldEvent);
- form.on("click", "["+options.validateAttribute+"*=validate][type=checkbox],["+options.validateAttribute+"*=validate][type=radio]", methods._onFieldEvent);
- form.on(options.validationEventTrigger,"["+options.validateAttribute+"*=validate][class*=datepicker]", {"delay": 300}, methods._onFieldEvent);
- }
- if (options.autoPositionUpdate) {
- $(window).bind("resize", {
- "noAnimation": true,
- "formElem": form
- }, methods.updatePromptsPosition);
- }
- form.on("click","a[data-validation-engine-skip], a[class*='validate-skip'], button[data-validation-engine-skip], button[class*='validate-skip'], input[data-validation-engine-skip], input[class*='validate-skip']", methods._submitButtonClick);
- form.removeData('jqv_submitButton');
-
- // bind form.submit
- form.on("submit", methods._onSubmitEvent);
- return this;
- },
- /**
- * Unregisters any bindings that may point to jQuery.validaitonEngine
- */
- detach: function() {
-
- var form = this;
- var options = form.data('jqv');
-
- // unbind fields
- form.find("["+options.validateAttribute+"*=validate]").not("[type=checkbox]").off(options.validationEventTrigger, methods._onFieldEvent);
- form.find("["+options.validateAttribute+"*=validate][type=checkbox],[class*=validate][type=radio]").off("click", methods._onFieldEvent);
-
- // unbind form.submit
- form.off("submit", methods._onSubmitEvent);
- form.removeData('jqv');
-
- form.off("click", "a[data-validation-engine-skip], a[class*='validate-skip'], button[data-validation-engine-skip], button[class*='validate-skip'], input[data-validation-engine-skip], input[class*='validate-skip']", methods._submitButtonClick);
- form.removeData('jqv_submitButton');
-
- if (options.autoPositionUpdate)
- $(window).off("resize", methods.updatePromptsPosition);
-
- return this;
- },
- /**
- * Validates either a form or a list of fields, shows prompts accordingly.
- * Note: There is no ajax form validation with this method, only field ajax validation are evaluated
- *
- * @return true if the form validates, false if it fails
- */
- validate: function() {
- var element = $(this);
- var valid = null;
-
- if (element.is("form") || element.hasClass("validationEngineContainer")) {
- if (element.hasClass('validating')) {
- // form is already validating.
- // Should abort old validation and start new one. I don't know how to implement it.
- return false;
- } else {
- element.addClass('validating');
- var options = element.data('jqv');
- var valid = methods._validateFields(this);
-
- // If the form doesn't validate, clear the 'validating' class before the user has a chance to submit again
- setTimeout(function(){
- element.removeClass('validating');
- }, 100);
- if (valid && options.onSuccess) {
- options.onSuccess();
- } else if (!valid && options.onFailure) {
- options.onFailure();
- }
- }
- } else if (element.is('form') || element.hasClass('validationEngineContainer')) {
- element.removeClass('validating');
- } else {
- // field validation
- var form = element.closest('form, .validationEngineContainer'),
- options = (form.data('jqv')) ? form.data('jqv') : $.validationEngine.defaults,
- valid = methods._validateField(element, options);
-
- if (valid && options.onFieldSuccess)
- options.onFieldSuccess();
- else if (options.onFieldFailure && options.InvalidFields.length > 0) {
- options.onFieldFailure();
- }
- }
- if(options.onValidationComplete) {
- // !! ensures that an undefined return is interpreted as return false but allows a onValidationComplete() to possibly return true and have form continue processing
- return !!options.onValidationComplete(form, valid);
- }
- return valid;
- },
- /**
- * Redraw prompts position, useful when you change the DOM state when validating
- */
- updatePromptsPosition: function(event) {
-
- if (event && this == window) {
- var form = event.data.formElem;
- var noAnimation = event.data.noAnimation;
- }
- else
- var form = $(this.closest('form, .validationEngineContainer'));
-
- var options = form.data('jqv');
- // No option, take default one
- form.find('['+options.validateAttribute+'*=validate]').not(":disabled").each(function(){
- var field = $(this);
- if (options.prettySelect && field.is(":hidden"))
- field = form.find("#" + options.usePrefix + field.attr('id') + options.useSuffix);
- var prompt = methods._getPrompt(field);
- var promptText = $(prompt).find(".formErrorContent").html();
-
- if(prompt)
- methods._updatePrompt(field, $(prompt), promptText, undefined, false, options, noAnimation);
- });
- return this;
- },
- /**
- * Displays a prompt on a element.
- * Note that the element needs an id!
- *
- * @param {String} promptText html text to display type
- * @param {String} type the type of bubble: 'pass' (green), 'load' (black) anything else (red)
- * @param {String} possible values topLeft, topRight, bottomLeft, centerRight, bottomRight
- */
- showPrompt: function(promptText, type, promptPosition, showArrow) {
- var form = this.closest('form, .validationEngineContainer');
- var options = form.data('jqv');
- // No option, take default one
- if(!options)
- options = methods._saveOptions(this, options);
- if(promptPosition)
- options.promptPosition=promptPosition;
- options.showArrow = showArrow==true;
-
- methods._showPrompt(this, promptText, type, false, options);
- return this;
- },
- /**
- * Closes form error prompts, CAN be invidual
- */
- hide: function() {
- var form = $(this).closest('form, .validationEngineContainer');
- var options = form.data('jqv');
- var fadeDuration = (options && options.fadeDuration) ? options.fadeDuration : 0.3;
- var closingtag;
-
- if($(this).is("form") || $(this).hasClass("validationEngineContainer")) {
- closingtag = "parentForm"+methods._getClassName($(this).attr("id"));
- } else {
- closingtag = methods._getClassName($(this).attr("id")) +"formError";
- }
- $('.'+closingtag).fadeTo(fadeDuration, 0.3, function() {
- $(this).parent('.formErrorOuter').remove();
- $(this).remove();
- });
- return this;
- },
- /**
- * Closes all error prompts on the page
- */
- hideAll: function() {
-
- var form = this;
- var options = form.data('jqv');
- var duration = options ? options.fadeDuration:300;
- $('.formError').fadeTo(duration, 300, function() {
- $(this).parent('.formErrorOuter').remove();
- $(this).remove();
- });
- return this;
- },
- /**
- * Typically called when user exists a field using tab or a mouse click, triggers a field
- * validation
- */
- _onFieldEvent: function(event) {
- var field = $(this);
- var form = field.closest('form, .validationEngineContainer');
- var options = form.data('jqv');
- options.eventTrigger = "field";
- // validate the current field
- window.setTimeout(function() {
- methods._validateField(field, options);
- if (options.InvalidFields.length == 0 && options.onFieldSuccess) {
- options.onFieldSuccess();
- } else if (options.InvalidFields.length > 0 && options.onFieldFailure) {
- options.onFieldFailure();
- }
- }, (event.data) ? event.data.delay : 0);
-
- },
- /**
- * Called when the form is submited, shows prompts accordingly
- *
- * @param {jqObject}
- * form
- * @return false if form submission needs to be cancelled
- */
- _onSubmitEvent: function() {
- var form = $(this);
- var options = form.data('jqv');
-
- //check if it is trigger from skipped button
- if (form.data("jqv_submitButton")){
- var submitButton = $("#" + form.data("jqv_submitButton"));
- if (submitButton){
- if (submitButton.length > 0){
- if (submitButton.hasClass("validate-skip") || submitButton.attr("data-validation-engine-skip") == "true")
- return true;
- }
- }
- }
-
- options.eventTrigger = "submit";
-
- // validate each field
- // (- skip field ajax validation, not necessary IF we will perform an ajax form validation)
- var r=methods._validateFields(form);
-
- if (r && options.ajaxFormValidation) {
- methods._validateFormWithAjax(form, options);
- // cancel form auto-submission - process with async call onAjaxFormComplete
- return false;
- }
-
- if(options.onValidationComplete) {
- // !! ensures that an undefined return is interpreted as return false but allows a onValidationComplete() to possibly return true and have form continue processing
- return !!options.onValidationComplete(form, r);
- }
- return r;
- },
- /**
- * Return true if the ajax field validations passed so far
- * @param {Object} options
- * @return true, is all ajax validation passed so far (remember ajax is async)
- */
- _checkAjaxStatus: function(options) {
- var status = true;
- $.each(options.ajaxValidCache, function(key, value) {
- if (!value) {
- status = false;
- // break the each
- return false;
- }
- });
- return status;
- },
-
- /**
- * Return true if the ajax field is validated
- * @param {String} fieldid
- * @param {Object} options
- * @return true, if validation passed, false if false or doesn't exist
- */
- _checkAjaxFieldStatus: function(fieldid, options) {
- return options.ajaxValidCache[fieldid] == true;
- },
- /**
- * Validates form fields, shows prompts accordingly
- *
- * @param {jqObject}
- * form
- * @param {skipAjaxFieldValidation}
- * boolean - when set to true, ajax field validation is skipped, typically used when the submit button is clicked
- *
- * @return true if form is valid, false if not, undefined if ajax form validation is done
- */
- _validateFields: function(form) {
- var options = form.data('jqv');
-
- // this variable is set to true if an error is found
- var errorFound = false;
-
- // Trigger hook, start validation
- form.trigger("jqv.form.validating");
- // first, evaluate status of non ajax fields
- var first_err=null;
- form.find('['+options.validateAttribute+'*=validate]').not(":disabled").each( function() {
- var field = $(this);
- var names = [];
- if ($.inArray(field.attr('name'), names) < 0) {
- errorFound |= methods._validateField(field, options);
- if (errorFound && first_err==null)
- if (field.is(":hidden") && options.prettySelect)
- first_err = field = form.find("#" + options.usePrefix + methods._jqSelector(field.attr('id')) + options.useSuffix);
- else {
-
- //Check if we need to adjust what element to show the prompt on
- //and and such scroll to instead
- if(field.data('jqv-prompt-at') instanceof jQuery ){
- field = field.data('jqv-prompt-at');
- } else if(field.data('jqv-prompt-at')) {
- field = $(field.data('jqv-prompt-at'));
- }
- first_err=field;
- }
- if (options.doNotShowAllErrosOnSubmit)
- return false;
- names.push(field.attr('name'));
-
- //if option set, stop checking validation rules after one error is found
- if(options.showOneMessage == true && errorFound){
- return false;
- }
- }
- });
-
- // second, check to see if all ajax calls completed ok
- // errorFound |= !methods._checkAjaxStatus(options);
-
- // third, check status and scroll the container accordingly
- form.trigger("jqv.form.result", [errorFound]);
-
- if (errorFound) {
- if (options.scroll) {
- var destination=first_err.offset().top;
- var fixleft = first_err.offset().left;
-
- //prompt positioning adjustment support. Usage: positionType:Xshift,Yshift (for ex.: bottomLeft:+20 or bottomLeft:-20,+10)
- var positionType=options.promptPosition;
- if (typeof(positionType)=='string' && positionType.indexOf(":")!=-1)
- positionType=positionType.substring(0,positionType.indexOf(":"));
-
- if (positionType!="bottomRight" && positionType!="bottomLeft") {
- var prompt_err= methods._getPrompt(first_err);
- if (prompt_err) {
- destination=prompt_err.offset().top;
- }
- }
-
- // Offset the amount the page scrolls by an amount in px to accomodate fixed elements at top of page
- if (options.scrollOffset) {
- destination -= options.scrollOffset;
- }
-
- // get the position of the first error, there should be at least one, no need to check this
- //var destination = form.find(".formError:not('.greenPopup'):first").offset().top;
- if (options.isOverflown) {
- var overflowDIV = $(options.overflownDIV);
- if(!overflowDIV.length) return false;
- var scrollContainerScroll = overflowDIV.scrollTop();
- var scrollContainerPos = -parseInt(overflowDIV.offset().top);
-
- destination += scrollContainerScroll + scrollContainerPos - 5;
- var scrollContainer = $(options.overflownDIV + ":not(:animated)");
-
- scrollContainer.animate({ scrollTop: destination }, 1100, function(){
- if(options.focusFirstField) first_err.focus();
- });
-
- } else {
- $("html, body").animate({
- scrollTop: destination
- }, 1100, function(){
- if(options.focusFirstField) first_err.focus();
- });
- $("html, body").animate({scrollLeft: fixleft},1100)
- }
-
- } else if(options.focusFirstField)
- first_err.focus();
- return false;
- }
- return true;
- },
- /**
- * This method is called to perform an ajax form validation.
- * During this process all the (field, value) pairs are sent to the server which returns a list of invalid fields or true
- *
- * @param {jqObject} form
- * @param {Map} options
- */
- _validateFormWithAjax: function(form, options) {
-
- var data = form.serialize();
- var type = (options.ajaxFormValidationMethod) ? options.ajaxFormValidationMethod : "GET";
- var url = (options.ajaxFormValidationURL) ? options.ajaxFormValidationURL : form.attr("action");
- var dataType = (options.dataType) ? options.dataType : "json";
- $.ajax({
- type: type,
- url: url,
- cache: false,
- dataType: dataType,
- data: data,
- form: form,
- methods: methods,
- options: options,
- beforeSend: function() {
- return options.onBeforeAjaxFormValidation(form, options);
- },
- error: function(data, transport) {
- methods._ajaxError(data, transport);
- },
- success: function(json) {
- if ((dataType == "json") && (json !== true)) {
- // getting to this case doesn't necessary means that the form is invalid
- // the server may return green or closing prompt actions
- // this flag helps figuring it out
- var errorInForm=false;
- for (var i = 0; i < json.length; i++) {
- var value = json[i];
-
- var errorFieldId = value[0];
- var errorField = $($("#" + errorFieldId)[0]);
-
- // make sure we found the element
- if (errorField.length == 1) {
-
- // promptText or selector
- var msg = value[2];
- // if the field is valid
- if (value[1] == true) {
-
- if (msg == "" || !msg){
- // if for some reason, status==true and error="", just close the prompt
- methods._closePrompt(errorField);
- } else {
- // the field is valid, but we are displaying a green prompt
- if (options.allrules[msg]) {
- var txt = options.allrules[msg].alertTextOk;
- if (txt)
- msg = txt;
- }
- if (options.showPrompts) methods._showPrompt(errorField, msg, "pass", false, options, true);
- }
- } else {
- // the field is invalid, show the red error prompt
- errorInForm|=true;
- if (options.allrules[msg]) {
- var txt = options.allrules[msg].alertText;
- if (txt)
- msg = txt;
- }
- if(options.showPrompts) methods._showPrompt(errorField, msg, "", false, options, true);
- }
- }
- }
- options.onAjaxFormComplete(!errorInForm, form, json, options);
- } else
- options.onAjaxFormComplete(true, form, json, options);
-
- }
- });
-
- },
- /**
- * Validates field, shows prompts accordingly
- *
- * @param {jqObject}
- * field
- * @param {Array[String]}
- * field's validation rules
- * @param {Map}
- * user options
- * @return false if field is valid (It is inversed for *fields*, it return false on validate and true on errors.)
- */
- _validateField: function(field, options, skipAjaxValidation) {
- if (!field.attr("id")) {
- field.attr("id", "form-validation-field-" + $.validationEngine.fieldIdCounter);
- ++$.validationEngine.fieldIdCounter;
- }
-
- if (!options.validateNonVisibleFields && (field.is(":hidden") && !options.prettySelect || field.parent().is(":hidden")))
- return false;
-
- var rulesParsing = field.attr(options.validateAttribute);
- var getRules = /validate\[(.*)\]/.exec(rulesParsing);
-
- if (!getRules)
- return false;
- var str = getRules[1];
- var rules = str.split(/\[|,|\]/);
-
- // true if we ran the ajax validation, tells the logic to stop messing with prompts
- var isAjaxValidator = false;
- var fieldName = field.attr("name");
- var promptText = "";
- var promptType = "";
- var required = false;
- var limitErrors = false;
- options.isError = false;
- options.showArrow = true;
-
- // If the programmer wants to limit the amount of error messages per field,
- if (options.maxErrorsPerField > 0) {
- limitErrors = true;
- }
-
- var form = $(field.closest("form, .validationEngineContainer"));
- // Fix for adding spaces in the rules
- for (var i = 0; i < rules.length; i++) {
- rules[i] = rules[i].replace(" ", "");
- // Remove any parsing errors
- if (rules[i] === '') {
- delete rules[i];
- }
- }
-
- for (var i = 0, field_errors = 0; i < rules.length; i++) {
-
- // If we are limiting errors, and have hit the max, break
- if (limitErrors && field_errors >= options.maxErrorsPerField) {
- // If we haven't hit a required yet, check to see if there is one in the validation rules for this
- // field and that it's index is greater or equal to our current index
- if (!required) {
- var have_required = $.inArray('required', rules);
- required = (have_required != -1 && have_required >= i);
- }
- break;
- }
-
-
- var errorMsg = undefined;
- switch (rules[i]) {
-
- case "required":
- required = true;
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._required);
- break;
- case "custom":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._custom);
- break;
- case "groupRequired":
- // Check is its the first of group, if not, reload validation with first field
- // AND continue normal validation on present field
- var classGroup = "["+options.validateAttribute+"*=" +rules[i + 1] +"]";
- var firstOfGroup = form.find(classGroup).eq(0);
- if(firstOfGroup[0] != field[0]){
-
- methods._validateField(firstOfGroup, options, skipAjaxValidation);
- options.showArrow = true;
-
- }
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._groupRequired);
- if(errorMsg) required = true;
- options.showArrow = false;
- break;
- case "ajax":
- // AJAX defaults to returning it's loading message
- errorMsg = methods._ajax(field, rules, i, options);
- if (errorMsg) {
- promptType = "load";
- }
- break;
- case "minSize":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._minSize);
- break;
- case "maxSize":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._maxSize);
- break;
- case "min":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._min);
- break;
- case "max":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._max);
- break;
- case "past":
- errorMsg = methods._getErrorMessage(form, field,rules[i], rules, i, options, methods._past);
- break;
- case "future":
- errorMsg = methods._getErrorMessage(form, field,rules[i], rules, i, options, methods._future);
- break;
- case "dateRange":
- var classGroup = "["+options.validateAttribute+"*=" + rules[i + 1] + "]";
- options.firstOfGroup = form.find(classGroup).eq(0);
- options.secondOfGroup = form.find(classGroup).eq(1);
-
- //if one entry out of the pair has value then proceed to run through validation
- if (options.firstOfGroup[0].value || options.secondOfGroup[0].value) {
- errorMsg = methods._getErrorMessage(form, field,rules[i], rules, i, options, methods._dateRange);
- }
- if (errorMsg) required = true;
- options.showArrow = false;
- break;
-
- case "dateTimeRange":
- var classGroup = "["+options.validateAttribute+"*=" + rules[i + 1] + "]";
- options.firstOfGroup = form.find(classGroup).eq(0);
- options.secondOfGroup = form.find(classGroup).eq(1);
-
- //if one entry out of the pair has value then proceed to run through validation
- if (options.firstOfGroup[0].value || options.secondOfGroup[0].value) {
- errorMsg = methods._getErrorMessage(form, field,rules[i], rules, i, options, methods._dateTimeRange);
- }
- if (errorMsg) required = true;
- options.showArrow = false;
- break;
- case "maxCheckbox":
- field = $(form.find("input[name='" + fieldName + "']"));
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._maxCheckbox);
- break;
- case "minCheckbox":
- field = $(form.find("input[name='" + fieldName + "']"));
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._minCheckbox);
- break;
- case "equals":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._equals);
- break;
- case "funcCall":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._funcCall);
- break;
- case "creditCard":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._creditCard);
- break;
- case "condRequired":
- errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._condRequired);
- if (errorMsg !== undefined) {
- required = true;
- }
- break;
-
- default:
- }
-
- var end_validation = false;
-
- // If we were passed back an message object, check what the status was to determine what to do
- if (typeof errorMsg == "object") {
- switch (errorMsg.status) {
- case "_break":
- end_validation = true;
- break;
- // If we have an error message, set errorMsg to the error message
- case "_error":
- errorMsg = errorMsg.message;
- break;
- // If we want to throw an error, but not show a prompt, return early with true
- case "_error_no_prompt":
- return true;
- break;
- // Anything else we continue on
- default:
- break;
- }
- }
-
- // If it has been specified that validation should end now, break
- if (end_validation) {
- break;
- }
-
- // If we have a string, that means that we have an error, so add it to the error message.
- if (typeof errorMsg == 'string') {
- promptText += errorMsg + " ";
- options.isError = true;
- field_errors++;
- }
- }
- // If the rules required is not added, an empty field is not validated
- if(!required && !(field.val()) && field.val().length < 1) options.isError = false;
-
- // Hack for radio/checkbox group button, the validation go into the
- // first radio/checkbox of the group
- var fieldType = field.prop("type");
- var positionType=field.data("promptPosition") || options.promptPosition;
-
- if ((fieldType == "radio" || fieldType == "checkbox") && form.find("input[name='" + fieldName + "']").size() > 1) {
- if(positionType === 'inline') {
- field = $(form.find("input[name='" + fieldName + "'][type!=hidden]:last"));
- } else {
- field = $(form.find("input[name='" + fieldName + "'][type!=hidden]:first"));
- }
- options.showArrow = false;
- }
-
- if(field.is(":hidden") && options.prettySelect) {
- field = form.find("#" + options.usePrefix + methods._jqSelector(field.attr('id')) + options.useSuffix);
- }
-
- if (options.isError && options.showPrompts){
- methods._showPrompt(field, promptText, promptType, false, options);
- }else{
- if (!isAjaxValidator) methods._closePrompt(field);
- }
-
- if (!isAjaxValidator) {
- field.trigger("jqv.field.result", [field, options.isError, promptText]);
- }
-
- /* Record error */
- var errindex = $.inArray(field[0], options.InvalidFields);
- if (errindex == -1) {
- if (options.isError)
- options.InvalidFields.push(field[0]);
- } else if (!options.isError) {
- options.InvalidFields.splice(errindex, 1);
- }
-
- methods._handleStatusCssClasses(field, options);
-
- /* run callback function for each field */
- if (options.isError && options.onFieldFailure)
- options.onFieldFailure(field);
-
- if (!options.isError && options.onFieldSuccess)
- options.onFieldSuccess(field);
-
- return options.isError;
- },
- /**
- * Handling css classes of fields indicating result of validation
- *
- * @param {jqObject}
- * field
- * @param {Array[String]}
- * field's validation rules
- * @private
- */
- _handleStatusCssClasses: function(field, options) {
- /* remove all classes */
- if(options.addSuccessCssClassToField)
- field.removeClass(options.addSuccessCssClassToField);
-
- if(options.addFailureCssClassToField)
- field.removeClass(options.addFailureCssClassToField);
-
- /* Add classes */
- if (options.addSuccessCssClassToField && !options.isError)
- field.addClass(options.addSuccessCssClassToField);
-
- if (options.addFailureCssClassToField && options.isError)
- field.addClass(options.addFailureCssClassToField);
- },
-
- /********************
- * _getErrorMessage
- *
- * @param form
- * @param field
- * @param rule
- * @param rules
- * @param i
- * @param options
- * @param originalValidationMethod
- * @return {*}
- * @private
- */
- _getErrorMessage:function (form, field, rule, rules, i, options, originalValidationMethod) {
- // If we are using the custon validation type, build the index for the rule.
- // Otherwise if we are doing a function call, make the call and return the object
- // that is passed back.
- var rule_index = jQuery.inArray(rule, rules);
- if (rule === "custom" || rule === "funcCall") {
- var custom_validation_type = rules[rule_index + 1];
- rule = rule + "[" + custom_validation_type + "]";
- // Delete the rule from the rules array so that it doesn't try to call the
- // same rule over again
- delete(rules[rule_index]);
- }
- // Change the rule to the composite rule, if it was different from the original
- var alteredRule = rule;
-
-
- var element_classes = (field.attr("data-validation-engine")) ? field.attr("data-validation-engine") : field.attr("class");
- var element_classes_array = element_classes.split(" ");
-
- // Call the original validation method. If we are dealing with dates or checkboxes, also pass the form
- var errorMsg;
- if (rule == "future" || rule == "past" || rule == "maxCheckbox" || rule == "minCheckbox") {
- errorMsg = originalValidationMethod(form, field, rules, i, options);
- } else {
- errorMsg = originalValidationMethod(field, rules, i, options);
- }
-
- // If the original validation method returned an error and we have a custom error message,
- // return the custom message instead. Otherwise return the original error message.
- if (errorMsg != undefined) {
- var custom_message = methods._getCustomErrorMessage($(field), element_classes_array, alteredRule, options);
- if (custom_message) errorMsg = custom_message;
- }
- return errorMsg;
-
- },
- _getCustomErrorMessage:function (field, classes, rule, options) {
- var custom_message = false;
- var validityProp = /^custom\[.*\]$/.test(rule) ? methods._validityProp["custom"] : methods._validityProp[rule];
- // If there is a validityProp for this rule, check to see if the field has an attribute for it
- if (validityProp != undefined) {
- custom_message = field.attr("data-errormessage-"+validityProp);
- // If there was an error message for it, return the message
- if (custom_message != undefined)
- return custom_message;
- }
- custom_message = field.attr("data-errormessage");
- // If there is an inline custom error message, return it
- if (custom_message != undefined)
- return custom_message;
- var id = '#' + field.attr("id");
- // If we have custom messages for the element's id, get the message for the rule from the id.
- // Otherwise, if we have custom messages for the element's classes, use the first class message we find instead.
- if (typeof options.custom_error_messages[id] != "undefined" &&
- typeof options.custom_error_messages[id][rule] != "undefined" ) {
- custom_message = options.custom_error_messages[id][rule]['message'];
- } else if (classes.length > 0) {
- for (var i = 0; i < classes.length && classes.length > 0; i++) {
- var element_class = "." + classes[i];
- if (typeof options.custom_error_messages[element_class] != "undefined" &&
- typeof options.custom_error_messages[element_class][rule] != "undefined") {
- custom_message = options.custom_error_messages[element_class][rule]['message'];
- break;
- }
- }
- }
- if (!custom_message &&
- typeof options.custom_error_messages[rule] != "undefined" &&
- typeof options.custom_error_messages[rule]['message'] != "undefined"){
- custom_message = options.custom_error_messages[rule]['message'];
- }
- return custom_message;
- },
- _validityProp: {
- "required": "value-missing",
- "custom": "custom-error",
- "groupRequired": "value-missing",
- "ajax": "custom-error",
- "minSize": "range-underflow",
- "maxSize": "range-overflow",
- "min": "range-underflow",
- "max": "range-overflow",
- "past": "type-mismatch",
- "future": "type-mismatch",
- "dateRange": "type-mismatch",
- "dateTimeRange": "type-mismatch",
- "maxCheckbox": "range-overflow",
- "minCheckbox": "range-underflow",
- "equals": "pattern-mismatch",
- "funcCall": "custom-error",
- "creditCard": "pattern-mismatch",
- "condRequired": "value-missing"
- },
- /**
- * Required validation
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @param {bool} condRequired flag when method is used for internal purpose in condRequired check
- * @return an error string if validation failed
- */
- _required: function(field, rules, i, options, condRequired) {
- switch (field.prop("type")) {
- case "text":
- case "password":
- case "textarea":
- case "file":
- case "select-one":
- case "select-multiple":
- default:
- var field_val = $.trim( field.val() );
- var dv_placeholder = $.trim( field.attr("data-validation-placeholder") );
- var placeholder = $.trim( field.attr("placeholder") );
- if (
- ( !field_val )
- || ( dv_placeholder && field_val == dv_placeholder )
- || ( placeholder && field_val == placeholder )
- ) {
- return options.allrules[rules[i]].alertText;
- }
- break;
- case "radio":
- case "checkbox":
- // new validation style to only check dependent field
- if (condRequired) {
- if (!field.attr('checked')) {
- return options.allrules[rules[i]].alertTextCheckboxMultiple;
- }
- break;
- }
- // old validation style
- var form = field.closest("form, .validationEngineContainer");
- var name = field.attr("name");
- if (form.find("input[name='" + name + "']:checked").size() == 0) {
- if (form.find("input[name='" + name + "']:visible").size() == 1)
- return options.allrules[rules[i]].alertTextCheckboxe;
- else
- return options.allrules[rules[i]].alertTextCheckboxMultiple;
- }
- break;
- }
- },
- /**
- * Validate that 1 from the group field is required
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _groupRequired: function(field, rules, i, options) {
- var classGroup = "["+options.validateAttribute+"*=" +rules[i + 1] +"]";
- var isValid = false;
- // Check all fields from the group
- field.closest("form, .validationEngineContainer").find(classGroup).each(function(){
- if(!methods._required($(this), rules, i, options)){
- isValid = true;
- return false;
- }
- });
-
- if(!isValid) {
- return options.allrules[rules[i]].alertText;
- }
- },
- /**
- * Validate rules
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _custom: function(field, rules, i, options) {
- var customRule = rules[i + 1];
- var rule = options.allrules[customRule];
- var fn;
- if(!rule) {
- alert("jqv:custom rule not found - "+customRule);
- return;
- }
-
- if(rule["regex"]) {
- var ex=rule.regex;
- if(!ex) {
- alert("jqv:custom regex not found - "+customRule);
- return;
- }
- var pattern = new RegExp(ex);
-
- if (!pattern.test(field.val())) return options.allrules[customRule].alertText;
-
- } else if(rule["func"]) {
- fn = rule["func"];
-
- if (typeof(fn) !== "function") {
- alert("jqv:custom parameter 'function' is no function - "+customRule);
- return;
- }
-
- if (!fn(field, rules, i, options))
- return options.allrules[customRule].alertText;
- } else {
- alert("jqv:custom type not allowed "+customRule);
- return;
- }
- },
- /**
- * Validate custom function outside of the engine scope
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _funcCall: function(field, rules, i, options) {
- var functionName = rules[i + 1];
- var fn;
- if(functionName.indexOf('.') >-1)
- {
- var namespaces = functionName.split('.');
- var scope = window;
- while(namespaces.length)
- {
- scope = scope[namespaces.shift()];
- }
- fn = scope;
- }
- else
- fn = window[functionName] || options.customFunctions[functionName];
- if (typeof(fn) == 'function')
- return fn(field, rules, i, options);
-
- },
- /**
- * Field match
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _equals: function(field, rules, i, options) {
- var equalsField = rules[i + 1];
-
- if (field.val() != $("#" + equalsField).val())
- return options.allrules.equals.alertText;
- },
- /**
- * Check the maximum size (in characters)
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _maxSize: function(field, rules, i, options) {
- var max = rules[i + 1];
- var len = field.val().length;
-
- if (len > max) {
- var rule = options.allrules.maxSize;
- return rule.alertText + max + rule.alertText2;
- }
- },
- /**
- * Check the minimum size (in characters)
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _minSize: function(field, rules, i, options) {
- var min = rules[i + 1];
- var len = field.val().length;
-
- if (len < min) {
- var rule = options.allrules.minSize;
- return rule.alertText + min + rule.alertText2;
- }
- },
- /**
- * Check number minimum value
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _min: function(field, rules, i, options) {
- var min = parseFloat(rules[i + 1]);
- var len = parseFloat(field.val());
-
- if (len < min) {
- var rule = options.allrules.min;
- if (rule.alertText2) return rule.alertText + min + rule.alertText2;
- return rule.alertText + min;
- }
- },
- /**
- * Check number maximum value
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _max: function(field, rules, i, options) {
- var max = parseFloat(rules[i + 1]);
- var len = parseFloat(field.val());
-
- if (len >max ) {
- var rule = options.allrules.max;
- if (rule.alertText2) return rule.alertText + max + rule.alertText2;
- //orefalo: to review, also do the translations
- return rule.alertText + max;
- }
- },
- /**
- * Checks date is in the past
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _past: function(form, field, rules, i, options) {
-
- var p=rules[i + 1];
- var fieldAlt = $(form.find("input[name='" + p.replace(/^#+/, '') + "']"));
- var pdate;
-
- if (p.toLowerCase() == "now") {
- pdate = new Date();
- } else if (undefined != fieldAlt.val()) {
- if (fieldAlt.is(":disabled"))
- return;
- pdate = methods._parseDate(fieldAlt.val());
- } else {
- pdate = methods._parseDate(p);
- }
- var vdate = methods._parseDate(field.val());
-
- if (vdate > pdate ) {
- var rule = options.allrules.past;
- if (rule.alertText2) return rule.alertText + methods._dateToString(pdate) + rule.alertText2;
- return rule.alertText + methods._dateToString(pdate);
- }
- },
- /**
- * Checks date is in the future
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _future: function(form, field, rules, i, options) {
-
- var p=rules[i + 1];
- var fieldAlt = $(form.find("input[name='" + p.replace(/^#+/, '') + "']"));
- var pdate;
-
- if (p.toLowerCase() == "now") {
- pdate = new Date();
- } else if (undefined != fieldAlt.val()) {
- if (fieldAlt.is(":disabled"))
- return;
- pdate = methods._parseDate(fieldAlt.val());
- } else {
- pdate = methods._parseDate(p);
- }
- var vdate = methods._parseDate(field.val());
-
- if (vdate < pdate ) {
- var rule = options.allrules.future;
- if (rule.alertText2)
- return rule.alertText + methods._dateToString(pdate) + rule.alertText2;
- return rule.alertText + methods._dateToString(pdate);
- }
- },
- /**
- * Checks if valid date
- *
- * @param {string} date string
- * @return a bool based on determination of valid date
- */
- _isDate: function (value) {
- var dateRegEx = new RegExp(/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/);
- return dateRegEx.test(value);
- },
- /**
- * Checks if valid date time
- *
- * @param {string} date string
- * @return a bool based on determination of valid date time
- */
- _isDateTime: function (value){
- var dateTimeRegEx = new RegExp(/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/);
- return dateTimeRegEx.test(value);
- },
- //Checks if the start date is before the end date
- //returns true if end is later than start
- _dateCompare: function (start, end) {
- return (new Date(start.toString()) < new Date(end.toString()));
- },
- /**
- * Checks date range
- *
- * @param {jqObject} first field name
- * @param {jqObject} second field name
- * @return an error string if validation failed
- */
- _dateRange: function (field, rules, i, options) {
- //are not both populated
- if ((!options.firstOfGroup[0].value && options.secondOfGroup[0].value) || (options.firstOfGroup[0].value && !options.secondOfGroup[0].value)) {
- return options.allrules[rules[i]].alertText + options.allrules[rules[i]].alertText2;
- }
-
- //are not both dates
- if (!methods._isDate(options.firstOfGroup[0].value) || !methods._isDate(options.secondOfGroup[0].value)) {
- return options.allrules[rules[i]].alertText + options.allrules[rules[i]].alertText2;
- }
-
- //are both dates but range is off
- if (!methods._dateCompare(options.firstOfGroup[0].value, options.secondOfGroup[0].value)) {
- return options.allrules[rules[i]].alertText + options.allrules[rules[i]].alertText2;
- }
- },
- /**
- * Checks date time range
- *
- * @param {jqObject} first field name
- * @param {jqObject} second field name
- * @return an error string if validation failed
- */
- _dateTimeRange: function (field, rules, i, options) {
- //are not both populated
- if ((!options.firstOfGroup[0].value && options.secondOfGroup[0].value) || (options.firstOfGroup[0].value && !options.secondOfGroup[0].value)) {
- return options.allrules[rules[i]].alertText + options.allrules[rules[i]].alertText2;
- }
- //are not both dates
- if (!methods._isDateTime(options.firstOfGroup[0].value) || !methods._isDateTime(options.secondOfGroup[0].value)) {
- return options.allrules[rules[i]].alertText + options.allrules[rules[i]].alertText2;
- }
- //are both dates but range is off
- if (!methods._dateCompare(options.firstOfGroup[0].value, options.secondOfGroup[0].value)) {
- return options.allrules[rules[i]].alertText + options.allrules[rules[i]].alertText2;
- }
- },
- /**
- * Max number of checkbox selected
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _maxCheckbox: function(form, field, rules, i, options) {
-
- var nbCheck = rules[i + 1];
- var groupname = field.attr("name");
- var groupSize = form.find("input[name='" + groupname + "']:checked").size();
- if (groupSize > nbCheck) {
- options.showArrow = false;
- if (options.allrules.maxCheckbox.alertText2)
- return options.allrules.maxCheckbox.alertText + " " + nbCheck + " " + options.allrules.maxCheckbox.alertText2;
- return options.allrules.maxCheckbox.alertText;
- }
- },
- /**
- * Min number of checkbox selected
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _minCheckbox: function(form, field, rules, i, options) {
-
- var nbCheck = rules[i + 1];
- var groupname = field.attr("name");
- var groupSize = form.find("input[name='" + groupname + "']:checked").size();
- if (groupSize < nbCheck) {
- options.showArrow = false;
- return options.allrules.minCheckbox.alertText + " " + nbCheck + " " + options.allrules.minCheckbox.alertText2;
- }
- },
- /**
- * Checks that it is a valid credit card number according to the
- * Luhn checksum algorithm.
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _creditCard: function(field, rules, i, options) {
- //spaces and dashes may be valid characters, but must be stripped to calculate the checksum.
- var valid = false, cardNumber = field.val().replace(/ +/g, '').replace(/-+/g, '');
-
- var numDigits = cardNumber.length;
- if (numDigits >= 14 && numDigits <= 16 && parseInt(cardNumber) > 0) {
-
- var sum = 0, i = numDigits - 1, pos = 1, digit, luhn = new String();
- do {
- digit = parseInt(cardNumber.charAt(i));
- luhn += (pos++ % 2 == 0) ? digit * 2 : digit;
- } while (--i >= 0)
-
- for (i = 0; i < luhn.length; i++) {
- sum += parseInt(luhn.charAt(i));
- }
- valid = sum % 10 == 0;
- }
- if (!valid) return options.allrules.creditCard.alertText;
- },
- /**
- * Ajax field validation
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return nothing! the ajax validator handles the prompts itself
- */
- _ajax: function(field, rules, i, options) {
-
- var errorSelector = rules[i + 1];
- var rule = options.allrules[errorSelector];
- var extraData = rule.extraData;
- var extraDataDynamic = rule.extraDataDynamic;
- var data = {
- "fieldId" : field.attr("id"),
- "fieldValue" : field.val()
- };
-
- if (typeof extraData === "object") {
- $.extend(data, extraData);
- } else if (typeof extraData === "string") {
- var tempData = extraData.split("&");
- for(var i = 0; i < tempData.length; i++) {
- var values = tempData[i].split("=");
- if (values[0] && values[0]) {
- data[values[0]] = values[1];
- }
- }
- }
-
- if (extraDataDynamic) {
- var tmpData = [];
- var domIds = String(extraDataDynamic).split(",");
- for (var i = 0; i < domIds.length; i++) {
- var id = domIds[i];
- if ($(id).length) {
- var inputValue = field.closest("form, .validationEngineContainer").find(id).val();
- var keyValue = id.replace('#', '') + '=' + escape(inputValue);
- data[id.replace('#', '')] = inputValue;
- }
- }
- }
-
- // If a field change event triggered this we want to clear the cache for this ID
- if (options.eventTrigger == "field") {
- delete(options.ajaxValidCache[field.attr("id")]);
- }
-
- // If there is an error or if the the field is already validated, do not re-execute AJAX
- if (!options.isError && !methods._checkAjaxFieldStatus(field.attr("id"), options)) {
- $.ajax({
- type: options.ajaxFormValidationMethod,
- url: rule.url,
- cache: false,
- dataType: "json",
- data: data,
- field: field,
- rule: rule,
- methods: methods,
- options: options,
- beforeSend: function() {},
- error: function(data, transport) {
- methods._ajaxError(data, transport);
- },
- success: function(json) {
-
- // asynchronously called on success, data is the json answer from the server
- var errorFieldId = json[0];
- //var errorField = $($("#" + errorFieldId)[0]);
- var errorField = $("#"+ errorFieldId).eq(0);
-
- // make sure we found the element
- if (errorField.length == 1) {
- var status = json[1];
- // read the optional msg from the server
- var msg = json[2];
- if (!status) {
- // Houston we got a problem - display an red prompt
- options.ajaxValidCache[errorFieldId] = false;
- options.isError = true;
-
- // resolve the msg prompt
- if(msg) {
- if (options.allrules[msg]) {
- var txt = options.allrules[msg].alertText;
- if (txt) {
- msg = txt;
- }
- }
- }
- else
- msg = rule.alertText;
-
- if (options.showPrompts) methods._showPrompt(errorField, msg, "", true, options);
- } else {
- options.ajaxValidCache[errorFieldId] = true;
-
- // resolves the msg prompt
- if(msg) {
- if (options.allrules[msg]) {
- var txt = options.allrules[msg].alertTextOk;
- if (txt) {
- msg = txt;
- }
- }
- }
- else
- msg = rule.alertTextOk;
-
- if (options.showPrompts) {
- // see if we should display a green prompt
- if (msg)
- methods._showPrompt(errorField, msg, "pass", true, options);
- else
- methods._closePrompt(errorField);
- }
-
- // If a submit form triggered this, we want to re-submit the form
- if (options.eventTrigger == "submit")
- field.closest("form").submit();
- }
- }
- errorField.trigger("jqv.field.result", [errorField, options.isError, msg]);
- }
- });
-
- return rule.alertTextLoad;
- }
- },
- /**
- * Common method to handle ajax errors
- *
- * @param {Object} data
- * @param {Object} transport
- */
- _ajaxError: function(data, transport) {
- if(data.status == 0 && transport == null)
- alert("The page is not served from a server! ajax call failed");
- else if(typeof console != "undefined")
- console.log("Ajax error: " + data.status + " " + transport);
- },
- /**
- * date -> string
- *
- * @param {Object} date
- */
- _dateToString: function(date) {
- return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
- },
- /**
- * Parses an ISO date
- * @param {String} d
- */
- _parseDate: function(d) {
-
- var dateParts = d.split("-");
- if(dateParts==d)
- dateParts = d.split("/");
- if(dateParts==d) {
- dateParts = d.split(".");
- return new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);
- }
- return new Date(dateParts[0], (dateParts[1] - 1) ,dateParts[2]);
- },
- /**
- * Builds or updates a prompt with the given information
- *
- * @param {jqObject} field
- * @param {String} promptText html text to display type
- * @param {String} type the type of bubble: 'pass' (green), 'load' (black) anything else (red)
- * @param {boolean} ajaxed - use to mark fields than being validated with ajax
- * @param {Map} options user options
- */
- _showPrompt: function(field, promptText, type, ajaxed, options, ajaxform) {
- //Check if we need to adjust what element to show the prompt on
- if(field.data('jqv-prompt-at') instanceof jQuery ){
- field = field.data('jqv-prompt-at');
- } else if(field.data('jqv-prompt-at')) {
- field = $(field.data('jqv-prompt-at'));
- }
-
- var prompt = methods._getPrompt(field);
- // The ajax submit errors are not see has an error in the form,
- // When the form errors are returned, the engine see 2 bubbles, but those are ebing closed by the engine at the same time
- // Because no error was found befor submitting
- if(ajaxform) prompt = false;
- // Check that there is indded text
- if($.trim(promptText)){
- if (prompt)
- methods._updatePrompt(field, prompt, promptText, type, ajaxed, options);
- else
- methods._buildPrompt(field, promptText, type, ajaxed, options);
- }
- },
- /**
- * Builds and shades a prompt for the given field.
- *
- * @param {jqObject} field
- * @param {String} promptText html text to display type
- * @param {String} type the type of bubble: 'pass' (green), 'load' (black) anything else (red)
- * @param {boolean} ajaxed - use to mark fields than being validated with ajax
- * @param {Map} options user options
- */
- _buildPrompt: function(field, promptText, type, ajaxed, options) {
-
- // create the prompt
- var prompt = $('
');
- prompt.addClass(methods._getClassName(field.attr("id")) + "formError");
- // add a class name to identify the parent form of the prompt
- prompt.addClass("parentForm"+methods._getClassName(field.closest('form, .validationEngineContainer').attr("id")));
- prompt.addClass("formError");
-
- switch (type) {
- case "pass":
- prompt.addClass("greenPopup");
- break;
- case "load":
- prompt.addClass("blackPopup");
- break;
- default:
- /* it has error */
- //alert("unknown popup type:"+type);
- }
- if (ajaxed)
- prompt.addClass("ajaxed");
-
- // create the prompt content
- var promptContent = $('
').addClass("formErrorContent").html(promptText).appendTo(prompt);
-
- // determine position type
- var positionType=field.data("promptPosition") || options.promptPosition;
-
- // create the css arrow pointing at the field
- // note that there is no triangle on max-checkbox and radio
- if (options.showArrow) {
- var arrow = $('
').addClass("formErrorArrow");
-
- //prompt positioning adjustment support. Usage: positionType:Xshift,Yshift (for ex.: bottomLeft:+20 or bottomLeft:-20,+10)
- if (typeof(positionType)=='string')
- {
- var pos=positionType.indexOf(":");
- if(pos!=-1)
- positionType=positionType.substring(0,pos);
- }
-
- switch (positionType) {
- case "bottomLeft":
- case "bottomRight":
- prompt.find(".formErrorContent").before(arrow);
- arrow.addClass("formErrorArrowBottom").html('');
- break;
- case "topLeft":
- case "topRight":
- arrow.html('');
- prompt.append(arrow);
- break;
- }
- }
- // Add custom prompt class
- if (options.addPromptClass)
- prompt.addClass(options.addPromptClass);
-
- // Add custom prompt class defined in element
- var requiredOverride = field.attr('data-required-class');
- if(requiredOverride !== undefined) {
- prompt.addClass(requiredOverride);
- } else {
- if(options.prettySelect) {
- if($('#' + field.attr('id')).next().is('select')) {
- var prettyOverrideClass = $('#' + field.attr('id').substr(options.usePrefix.length).substring(options.useSuffix.length)).attr('data-required-class');
- if(prettyOverrideClass !== undefined) {
- prompt.addClass(prettyOverrideClass);
- }
- }
- }
- }
-
- prompt.css({
- "opacity": 0
- });
- if(positionType === 'inline') {
- prompt.addClass("inline");
- if(typeof field.attr('data-prompt-target') !== 'undefined' && $('#'+field.attr('data-prompt-target')).length > 0) {
- prompt.appendTo($('#'+field.attr('data-prompt-target')));
- } else {
- field.after(prompt);
- }
- } else {
- field.before(prompt);
- }
-
- var pos = methods._calculatePosition(field, prompt, options);
- prompt.css({
- 'position': positionType === 'inline' ? 'relative' : 'absolute',
- "top": pos.callerTopPosition,
- "left": pos.callerleftPosition,
- "marginTop": pos.marginTopSize,
- "opacity": 0
- }).data("callerField", field);
-
-
- if (options.autoHidePrompt) {
- setTimeout(function(){
- prompt.animate({
- "opacity": 0
- },function(){
- prompt.closest('.formErrorOuter').remove();
- prompt.remove();
- });
- }, options.autoHideDelay);
- }
- return prompt.animate({
- "opacity": 0.87
- });
- },
- /**
- * Updates the prompt text field - the field for which the prompt
- * @param {jqObject} field
- * @param {String} promptText html text to display type
- * @param {String} type the type of bubble: 'pass' (green), 'load' (black) anything else (red)
- * @param {boolean} ajaxed - use to mark fields than being validated with ajax
- * @param {Map} options user options
- */
- _updatePrompt: function(field, prompt, promptText, type, ajaxed, options, noAnimation) {
-
- if (prompt) {
- if (typeof type !== "undefined") {
- if (type == "pass")
- prompt.addClass("greenPopup");
- else
- prompt.removeClass("greenPopup");
-
- if (type == "load")
- prompt.addClass("blackPopup");
- else
- prompt.removeClass("blackPopup");
- }
- if (ajaxed)
- prompt.addClass("ajaxed");
- else
- prompt.removeClass("ajaxed");
-
- prompt.find(".formErrorContent").html(promptText);
-
- var pos = methods._calculatePosition(field, prompt, options);
- var css = {"top": pos.callerTopPosition,
- "left": pos.callerleftPosition,
- "marginTop": pos.marginTopSize};
-
- if (noAnimation)
- prompt.css(css);
- else
- prompt.animate(css);
- }
- },
- /**
- * Closes the prompt associated with the given field
- *
- * @param {jqObject}
- * field
- */
- _closePrompt: function(field) {
- var prompt = methods._getPrompt(field);
- if (prompt)
- prompt.fadeTo("fast", 0, function() {
- prompt.parent('.formErrorOuter').remove();
- prompt.remove();
- });
- },
- closePrompt: function(field) {
- return methods._closePrompt(field);
- },
- /**
- * Returns the error prompt matching the field if any
- *
- * @param {jqObject}
- * field
- * @return undefined or the error prompt (jqObject)
- */
- _getPrompt: function(field) {
- var formId = $(field).closest('form, .validationEngineContainer').attr('id');
- var className = methods._getClassName(field.attr("id")) + "formError";
- var match = $("." + methods._escapeExpression(className) + '.parentForm' + methods._getClassName(formId))[0];
- if (match)
- return $(match);
- },
- /**
- * Returns the escapade classname
- *
- * @param {selector}
- * className
- */
- _escapeExpression: function (selector) {
- return selector.replace(/([#;&,\.\+\*\~':"\!\^$\[\]\(\)=>\|])/g, "\\$1");
- },
- /**
- * returns true if we are in a RTLed document
- *
- * @param {jqObject} field
- */
- isRTL: function(field)
- {
- var $document = $(document);
- var $body = $('body');
- var rtl =
- (field && field.hasClass('rtl')) ||
- (field && (field.attr('dir') || '').toLowerCase()==='rtl') ||
- $document.hasClass('rtl') ||
- ($document.attr('dir') || '').toLowerCase()==='rtl' ||
- $body.hasClass('rtl') ||
- ($body.attr('dir') || '').toLowerCase()==='rtl';
- return Boolean(rtl);
- },
- /**
- * Calculates prompt position
- *
- * @param {jqObject}
- * field
- * @param {jqObject}
- * the prompt
- * @param {Map}
- * options
- * @return positions
- */
- _calculatePosition: function (field, promptElmt, options) {
-
- var promptTopPosition, promptleftPosition, marginTopSize;
- var fieldWidth = field.width();
- var fieldLeft = field.position().left;
- var fieldTop = field.position().top;
- var fieldHeight = field.height();
- var promptHeight = promptElmt.height();
-
-
- // is the form contained in an overflown container?
- promptTopPosition = promptleftPosition = 0;
- // compensation for the arrow
- marginTopSize = -promptHeight;
-
-
- //prompt positioning adjustment support
- //now you can adjust prompt position
- //usage: positionType:Xshift,Yshift
- //for example:
- // bottomLeft:+20 means bottomLeft position shifted by 20 pixels right horizontally
- // topRight:20, -15 means topRight position shifted by 20 pixels to right and 15 pixels to top
- //You can use +pixels, - pixels. If no sign is provided than + is default.
- var positionType=field.data("promptPosition") || options.promptPosition;
- var shift1="";
- var shift2="";
- var shiftX=0;
- var shiftY=0;
- if (typeof(positionType)=='string') {
- //do we have any position adjustments ?
- if (positionType.indexOf(":")!=-1) {
- shift1=positionType.substring(positionType.indexOf(":")+1);
- positionType=positionType.substring(0,positionType.indexOf(":"));
-
- //if any advanced positioning will be needed (percents or something else) - parser should be added here
- //for now we use simple parseInt()
-
- //do we have second parameter?
- if (shift1.indexOf(",") !=-1) {
- shift2=shift1.substring(shift1.indexOf(",") +1);
- shift1=shift1.substring(0,shift1.indexOf(","));
- shiftY=parseInt(shift2);
- if (isNaN(shiftY)) shiftY=0;
- };
-
- shiftX=parseInt(shift1);
- if (isNaN(shift1)) shift1=0;
-
- };
- };
-
-
- switch (positionType) {
- default:
- case "topRight":
- promptleftPosition += fieldLeft + fieldWidth - 30;
- promptTopPosition += fieldTop;
- break;
-
- case "topLeft":
- promptTopPosition += fieldTop;
- promptleftPosition += fieldLeft;
- break;
-
- case "centerRight":
- promptTopPosition = fieldTop+4;
- marginTopSize = 0;
- promptleftPosition= fieldLeft + field.outerWidth(true)+5;
- break;
- case "centerLeft":
- promptleftPosition = fieldLeft - (promptElmt.width() + 2);
- promptTopPosition = fieldTop+4;
- marginTopSize = 0;
-
- break;
-
- case "bottomLeft":
- promptTopPosition = fieldTop + field.height() + 5;
- marginTopSize = 0;
- promptleftPosition = fieldLeft;
- break;
- case "bottomRight":
- promptleftPosition = fieldLeft + fieldWidth - 30;
- promptTopPosition = fieldTop + field.height() + 5;
- marginTopSize = 0;
- break;
- case "inline":
- promptleftPosition = 0;
- promptTopPosition = 0;
- marginTopSize = 0;
- };
-
-
-
- //apply adjusments if any
- promptleftPosition += shiftX;
- promptTopPosition += shiftY;
-
- return {
- "callerTopPosition": promptTopPosition + "px",
- "callerleftPosition": promptleftPosition + "px",
- "marginTopSize": marginTopSize + "px"
- };
- },
- /**
- * Saves the user options and variables in the form.data
- *
- * @param {jqObject}
- * form - the form where the user option should be saved
- * @param {Map}
- * options - the user options
- * @return the user options (extended from the defaults)
- */
- _saveOptions: function(form, options) {
-
- // is there a language localisation ?
- if ($.validationEngineLanguage)
- var allRules = $.validationEngineLanguage.allRules;
- else
- $.error("jQuery.validationEngine rules are not loaded, plz add localization files to the page");
- // --- Internals DO NOT TOUCH or OVERLOAD ---
- // validation rules and i18
- $.validationEngine.defaults.allrules = allRules;
-
- var userOptions = $.extend(true,{},$.validationEngine.defaults,options);
-
- form.data('jqv', userOptions);
- return userOptions;
- },
-
- /**
- * Removes forbidden characters from class name
- * @param {String} className
- */
- _getClassName: function(className) {
- if(className)
- return className.replace(/:/g, "_").replace(/\./g, "_");
- },
- /**
- * Escape special character for jQuery selector
- * http://totaldev.com/content/escaping-characters-get-valid-jquery-id
- * @param {String} selector
- */
- _jqSelector: function(str){
- return str.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
- },
- /**
- * Conditionally required field
- *
- * @param {jqObject} field
- * @param {Array[String]} rules
- * @param {int} i rules index
- * @param {Map}
- * user options
- * @return an error string if validation failed
- */
- _condRequired: function(field, rules, i, options) {
- var idx, dependingField;
-
- for(idx = (i + 1); idx < rules.length; idx++) {
- dependingField = jQuery("#" + rules[idx]).first();
-
- /* Use _required for determining wether dependingField has a value.
- * There is logic there for handling all field types, and default value; so we won't replicate that here
- * Indicate this special use by setting the last parameter to true so we only validate the dependingField on chackboxes and radio buttons (#462)
- */
- if (dependingField.length && methods._required(dependingField, ["required"], 0, options, true) == undefined) {
- /* We now know any of the depending fields has a value,
- * so we can validate this field as per normal required code
- */
- return methods._required(field, ["required"], 0, options);
- }
- }
- },
-
- _submitButtonClick: function(event) {
- var button = $(this);
- var form = button.closest('form, .validationEngineContainer');
- form.data("jqv_submitButton", button.attr("id"));
- }
- };
-
- /**
- * Plugin entry point.
- * You may pass an action as a parameter or a list of options.
- * if none, the init and attach methods are being called.
- * Remember: if you pass options, the attached method is NOT called automatically
- *
- * @param {String}
- * method (optional) action
- */
- $.fn.validationEngine = function(method) {
-
- var form = $(this);
- if(!form[0]) return form; // stop here if the form does not exist
-
- if (typeof(method) == 'string' && method.charAt(0) != '_' && methods[method]) {
-
- // make sure init is called once
- if(method != "showPrompt" && method != "hide" && method != "hideAll")
- methods.init.apply(form);
-
- return methods[method].apply(form, Array.prototype.slice.call(arguments, 1));
- } else if (typeof method == 'object' || !method) {
-
- // default constructor with or without arguments
- methods.init.apply(form, arguments);
- return methods.attach.apply(form);
- } else {
- $.error('Method ' + method + ' does not exist in jQuery.validationEngine');
- }
- };
-
-
-
- // LEAK GLOBAL OPTIONS
- $.validationEngine= {fieldIdCounter: 0,defaults:{
-
- // Name of the event triggering field validation
- validationEventTrigger: "blur",
- // Automatically scroll viewport to the first error
- scroll: true,
- // Focus on the first input
- focusFirstField:true,
- // Show prompts, set to false to disable prompts
- showPrompts: true,
- // Should we attempt to validate non-visible input fields contained in the form? (Useful in cases of tabbed containers, e.g. jQuery-UI tabs)
- validateNonVisibleFields: false,
- // Opening box position, possible locations are: topLeft,
- // topRight, bottomLeft, centerRight, bottomRight, inline
- // inline gets inserted after the validated field or into an element specified in data-prompt-target
- promptPosition: "topRight",
- bindMethod:"bind",
- // internal, automatically set to true when it parse a _ajax rule
- inlineAjax: false,
- // if set to true, the form data is sent asynchronously via ajax to the form.action url (get)
- ajaxFormValidation: false,
- // The url to send the submit ajax validation (default to action)
- ajaxFormValidationURL: false,
- // HTTP method used for ajax validation
- ajaxFormValidationMethod: 'get',
- // Ajax form validation callback method: boolean onComplete(form, status, errors, options)
- // retuns false if the form.submit event needs to be canceled.
- onAjaxFormComplete: $.noop,
- // called right before the ajax call, may return false to cancel
- onBeforeAjaxFormValidation: $.noop,
- // Stops form from submitting and execute function assiciated with it
- onValidationComplete: false,
-
- // Used when you have a form fields too close and the errors messages are on top of other disturbing viewing messages
- doNotShowAllErrosOnSubmit: false,
- // Object where you store custom messages to override the default error messages
- custom_error_messages:{},
- // true if you want to vind the input fields
- binded: true,
- // set to true, when the prompt arrow needs to be displayed
- showArrow: true,
- // did one of the validation fail ? kept global to stop further ajax validations
- isError: false,
- // Limit how many displayed errors a field can have
- maxErrorsPerField: false,
-
- // Caches field validation status, typically only bad status are created.
- // the array is used during ajax form validation to detect issues early and prevent an expensive submit
- ajaxValidCache: {},
- // Auto update prompt position after window resize
- autoPositionUpdate: false,
-
- InvalidFields: [],
- onFieldSuccess: false,
- onFieldFailure: false,
- onSuccess: false,
- onFailure: false,
- validateAttribute: "class",
- addSuccessCssClassToField: "",
- addFailureCssClassToField: "",
-
- // Auto-hide prompt
- autoHidePrompt: false,
- // Delay before auto-hide
- autoHideDelay: 10000,
- // Fade out duration while hiding the validations
- fadeDuration: 0.3,
- // Use Prettify select library
- prettySelect: false,
- // Add css class on prompt
- addPromptClass : "",
- // Custom ID uses prefix
- usePrefix: "",
- // Custom ID uses suffix
- useSuffix: "",
- // Only show one message per error prompt
- showOneMessage: false
- }};
- $(function(){$.validationEngine.defaults.promptPosition = methods.isRTL()?'topLeft':"topRight"});
-})(jQuery);
-
-
diff --git a/WebRoot/js/kindeditor/kindeditor-min.js b/WebRoot/js/kindeditor/kindeditor-min.js
new file mode 100644
index 0000000..842584a
--- /dev/null
+++ b/WebRoot/js/kindeditor/kindeditor-min.js
@@ -0,0 +1,173 @@
+/* KindEditor 4.0.6 (2012-03-18), Copyright (C) kindsoft.net, Licence: http://www.kindsoft.net/license.php */(function(z,j){function ba(a){if(!a)return!1;return Object.prototype.toString.call(a)==="[object Array]"}function $a(a){if(!a)return!1;return Object.prototype.toString.call(a)==="[object Function]"}function L(a,b){for(var c=0,d=b.length;c=0}function p(a){return a&&/^\d+$/.test(a)?a+"px":a}function t(a){var b;return a&&(b=/(\d+)/.exec(a))?parseInt(b[1],10):0}function B(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function ab(a){return a.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function ca(a){var b=a.split("-"),a="";m(b,function(b,d){a+=b>0?d.charAt(0).toUpperCase()+d.substr(1):
+d});return a}function na(a){function b(a){a=parseInt(a,10).toString(16).toUpperCase();return a.length>1?a:"0"+a}return a.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/ig,function(a,d,e,g){return"#"+b(d)+b(e)+b(g)})}function u(a,b){var b=b===j?",":b,c={},d=ba(a)?a:a.split(b),e;m(d,function(a,b){if(e=/^(\d+)\.\.(\d+)$/.exec(b))for(var d=parseInt(e[1],10);d<=parseInt(e[2],10);d++)c[d.toString()]=!0;else c[b]=!0});return c}function Ea(a,b){return Array.prototype.slice.call(a,b||0)}function l(a,
+b){return a===j?b:a}function D(a,b,c){c||(c=b,b=null);var d;if(b){var e=function(){};e.prototype=b.prototype;d=new e;m(c,function(a,b){d[a]=b})}else d=c;d.constructor=a;a.prototype=d;a.parent=b?b.prototype:null}function bb(a){var b;if(b=/\{[\s\S]*\}|\[[\s\S]*\]/.exec(a))a=b[0];b=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;b.lastIndex=0;b.test(a)&&(a=a.replace(b,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));
+if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return eval("("+a+")");throw"JSON parse error";}function Ob(a,b,c){a.addEventListener?a.addEventListener(b,c,cb):a.attachEvent&&a.attachEvent("on"+b,c)}function oa(a,b,c){a.removeEventListener?a.removeEventListener(b,c,cb):a.detachEvent&&a.detachEvent("on"+b,c)}function db(a,b){this.init(a,b)}function eb(a){try{delete a[V]}catch(b){a.removeAttribute&&
+a.removeAttribute(V)}}function W(a,b,c){if(b.indexOf(",")>=0)m(b.split(","),function(){W(a,this,c)});else{var d=a[V]||null;d||(a[V]=++fb,d=fb);q[d]===j&&(q[d]={});var e=q[d][b];e&&e.length>0?oa(a,b,e[0]):(q[d][b]=[],q[d].el=a);e=q[d][b];e.length===0&&(e[0]=function(b){var c=b?new db(a,b):j;m(e,function(b,d){b>0&&d&&d.call(a,c)})});L(c,e)<0&&e.push(c);Ob(a,b,e[0])}}function da(a,b,c){if(b&&b.indexOf(",")>=0)m(b.split(","),function(){da(a,this,c)});else{var d=a[V]||null;if(d)if(b===j)d in q&&(m(q[d],
+function(b,c){b!="el"&&c.length>0&&oa(a,b,c[0])}),delete q[d],eb(a));else if(q[d]){var e=q[d][b];if(e&&e.length>0){c===j?(oa(a,b,e[0]),delete q[d][b]):(m(e,function(a,b){a>0&&b===c&&e.splice(a,1)}),e.length==1&&(oa(a,b,e[0]),delete q[d][b]));var g=0;m(q[d],function(){g++});g<2&&(delete q[d],eb(a))}}}}function gb(a,b){if(b.indexOf(",")>=0)m(b.split(","),function(){gb(a,this)});else{var c=a[V]||null;if(c){var d=q[c][b];if(q[c]&&d&&d.length>0)d[0]()}}}function Fa(a,b,c){b=/^\d{2,}$/.test(b)?b:b.toUpperCase().charCodeAt(0);
+W(a,"keydown",function(d){d.ctrlKey&&d.which==b&&!d.shiftKey&&!d.altKey&&(c.call(a),d.stop())})}function ea(a){for(var b={},c=/\s*([\w\-]+)\s*:([^;]*)(;|$)/g,d;d=c.exec(a);){var e=A(d[1].toLowerCase());d=A(na(d[2]));b[e]=d}return b}function J(a){for(var b={},c=/\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g,d;d=c.exec(a);){var e=(d[1]||d[2]||d[4]||d[6]).toLowerCase();b[e]=(d[2]?d[3]:d[4]?d[5]:d[7])||""}return b}function Pb(a,b){return a=
+/\s+class\s*=/.test(a)?a.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/,function(a,d,e,g){return(" "+e+" ").indexOf(" "+b+" ")<0?e===""?d+b+g:d+e+" "+b+g:a}):a.substr(0,a.length-1)+' class="'+b+'">'}function Qb(a){var b="";m(ea(a),function(a,d){b+=a+":"+d+";"});return b}function pa(a,b,c,d){function e(a){for(var a=a.split("/"),b=[],c=0,d=a.length;c0&&b.pop():e!==""&&e!="."&&b.push(e)}return"/"+b.join("/")}function g(b,c){if(a.substr(0,b.length)===b){for(var e=[],
+h=0;h0&&(h+="/"+e.join("/"));d=="/"&&(h+="/");return h+a.substr(b.length)}else if(f=/^(.*)\//.exec(b))return g(f[1],++c)}b=l(b,"").toLowerCase();if(L(b,["absolute","relative","domain"])<0)return a;c=c||location.protocol+"//"+location.host;if(d===j)var h=location.pathname.match(/^(\/.*)\//),d=h?h[1]:"";var f;if(f=/^(\w+:\/\/[^\/]*)/.exec(a)){if(f[1]!==c)return a}else if(/^\w+:/.test(a))return a;/^\//.test(a)?a=c+e(a.substr(1)):/^\w+:\/\//.test(a)||(a=c+e(d+"/"+a));
+b==="relative"?a=g(c+d,0).substr(2):b==="absolute"&&a.substr(0,c.length)===c&&(a=a.substr(c.length));return a}function Q(a,b,c,d,e){var c=c||"",d=l(d,!1),e=l(e,"\t"),g="xx-small,x-small,small,medium,large,x-large,xx-large".split(","),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig,function(a,b,c,d){return b+c.replace(/<(?:br|br\s[^>]*)>/ig,"\n")+d}),a=a.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/ig,""),a=a.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/ig,"$1 $2"),a=a.replace(/\u200B/g,""),
+h={};b&&(m(b,function(a,b){for(var c=a.split(","),d=0,e=c.length;d]*)>)([\s\S]*?)(<\/script>)/ig,"")),h.style||(a=a.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/ig,"")));var f=[],a=a.replace(/(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g,function(a,n,s,r,qa,C,E){var n=n||"",s=s||"",j=r.toLowerCase(),l=qa||"",r=C?" "+C:"",E=E||
+"";if(b&&!h[j])return"";r===""&&hb[j]&&(r=" /");ib[j]&&(n&&(n=" "),E&&(E=" "));Ga[j]&&(s?E="\n":n="\n");d&&j=="br"&&(E="\n");if(jb[j]&&!Ga[j])if(d){s&&f.length>0&&f[f.length-1]===j?f.pop():f.push(j);E=n="\n";qa=0;for(C=s?f.length:f.length-1;qa=0&&(w[a]=pa(d,c));(b&&a!=="style"&&!h[j]["*"]&&!h[j][a]||j==="body"&&a==="contenteditable"||/^kindeditor_\d+$/.test(a))&&delete w[a];if(a==="style"&&d!==""){var e=ea(d);m(e,function(a){b&&!h[j].style&&!h[j]["."+a]&&delete e[a]});var g="";m(e,function(a,b){g+=a+":"+b+";"});w.style=g}});l="";m(w,function(a,
+b){a==="style"&&b===""||(b=b.replace(/"/g,"""),l+=" "+a+'="'+b+'"')})}j==="font"&&(j="span");return n+"<"+s+j+l+r+">"+E}),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig,function(a,b,c,d){return b+c.replace(/\n/g,'\n')+d}),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/\n/g,"\n");return A(a)}function kb(a,b){a=a.replace(//ig,"").replace(//ig,"").replace(/"];ba(c)||(c=[c]);m(c,function(a,b){b&&e.push('')});d&&e.push("");e.push("