All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.bootstrap-validator.js.validator.min.js Maven / Gradle / Ivy

There is a newer version: 0.66.0.1
Show newest version
+function($){"use strict";function getValue($el){return $el.is('[type="checkbox"]')?$el.prop("checked"):$el.is('[type="radio"]')?!!$('[name="'+$el.attr("name")+'"]:checked').length:$el.is("select[multiple]")?($el.val()||[]).length:$el.val()}var Validator=function(element,options){this.options=options;this.validators=$.extend({},Validator.VALIDATORS,options.custom);this.$element=$(element);this.$btn=$('button[type="submit"], input[type="submit"]').filter('[form="'+this.$element.attr("id")+'"]').add(this.$element.find('input[type="submit"], button[type="submit"]'));this.update();this.$element.on("input.bs.validator change.bs.validator focusout.bs.validator",$.proxy(this.onInput,this));this.$element.on("submit.bs.validator",$.proxy(this.onSubmit,this));this.$element.on("reset.bs.validator",$.proxy(this.reset,this));this.$element.find("[data-match]").each(function(){var $this=$(this);var target=$this.attr("data-match");$(target).on("input.bs.validator",function(e){getValue($this)&&$this.trigger("input.bs.validator")})});this.$inputs.filter(function(){return getValue($(this))&&!$(this).closest(".has-error").length}).trigger("focusout");this.$element.attr("novalidate",true)};Validator.VERSION="0.11.9";Validator.INPUT_SELECTOR=':input:not([type="hidden"], [type="submit"], [type="reset"], button)';Validator.FOCUS_OFFSET=20;Validator.DEFAULTS={delay:500,html:false,disable:true,focus:true,custom:{},errors:{match:"Does not match",minlength:"Not long enough"},feedback:{success:"glyphicon-ok",error:"glyphicon-remove"}};Validator.VALIDATORS={native:function($el){var el=$el[0];if(el.checkValidity){return!el.checkValidity()&&!el.validity.valid&&(el.validationMessage||"error!")}},match:function($el){var target=$el.attr("data-match");return $el.val()!==$(target).val()&&Validator.DEFAULTS.errors.match},minlength:function($el){var minlength=$el.attr("data-minlength");return $el.val().length").addClass("list-unstyled").append($.map(errors,function(error){return $("
  • ")[method](error)}));$block.data("bs.validator.originalContent")===undefined&&$block.data("bs.validator.originalContent",$block.html());$block.empty().append(errors);$group.addClass("has-error has-danger");$group.hasClass("has-feedback")&&$feedback.removeClass(this.options.feedback.success)&&$feedback.addClass(this.options.feedback.error)&&$group.removeClass("has-success")};Validator.prototype.clearErrors=function($el){var $group=$el.closest(".form-group");var $block=$group.find(".help-block.with-errors");var $feedback=$group.find(".form-control-feedback");$block.html($block.data("bs.validator.originalContent"));$group.removeClass("has-error has-danger has-success");$group.hasClass("has-feedback")&&$feedback.removeClass(this.options.feedback.error)&&$feedback.removeClass(this.options.feedback.success)&&getValue($el)&&$feedback.addClass(this.options.feedback.success)&&$group.addClass("has-success")};Validator.prototype.hasErrors=function(){function fieldErrors(){return!!($(this).data("bs.validator.errors")||[]).length}return!!this.$inputs.filter(fieldErrors).length};Validator.prototype.isIncomplete=function(){function fieldIncomplete(){var value=getValue($(this));return!(typeof value=="string"?$.trim(value):value)}return!!this.$inputs.filter("[required]").filter(fieldIncomplete).length};Validator.prototype.onSubmit=function(e){this.validate();if(this.isIncomplete()||this.hasErrors())e.preventDefault()};Validator.prototype.toggleSubmit=function(){if(!this.options.disable)return;this.$btn.toggleClass("disabled",this.isIncomplete()||this.hasErrors())};Validator.prototype.defer=function($el,callback){callback=$.proxy(callback,this,$el);if(!this.options.delay)return callback();window.clearTimeout($el.data("bs.validator.timeout"));$el.data("bs.validator.timeout",window.setTimeout(callback,this.options.delay))};Validator.prototype.reset=function(){this.$element.find(".form-control-feedback").removeClass(this.options.feedback.error).removeClass(this.options.feedback.success);this.$inputs.removeData(["bs.validator.errors","bs.validator.deferred"]).each(function(){var $this=$(this);var timeout=$this.data("bs.validator.timeout");window.clearTimeout(timeout)&&$this.removeData("bs.validator.timeout")});this.$element.find(".help-block.with-errors").each(function(){var $this=$(this);var originalContent=$this.data("bs.validator.originalContent");$this.removeData("bs.validator.originalContent").html(originalContent)});this.$btn.removeClass("disabled");this.$element.find(".has-error, .has-danger, .has-success").removeClass("has-error has-danger has-success");return this};Validator.prototype.destroy=function(){this.reset();this.$element.removeAttr("novalidate").removeData("bs.validator").off(".bs.validator");this.$inputs.off(".bs.validator");this.options=null;this.validators=null;this.$element=null;this.$btn=null;this.$inputs=null;return this};function Plugin(option){return this.each(function(){var $this=$(this);var options=$.extend({},Validator.DEFAULTS,$this.data(),typeof option=="object"&&option);var data=$this.data("bs.validator");if(!data&&option=="destroy")return;if(!data)$this.data("bs.validator",data=new Validator(this,options));if(typeof option=="string")data[option]()})}var old=$.fn.validator;$.fn.validator=Plugin;$.fn.validator.Constructor=Validator;$.fn.validator.noConflict=function(){$.fn.validator=old;return this};$(window).on("load",function(){$('form[data-toggle="validator"]').each(function(){var $form=$(this);Plugin.call($form,$form.data())})})}(jQuery);




  • © 2015 - 2024 Weber Informatics LLC | Privacy Policy