diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e877e..2e1edbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,25 @@ Changelog ========= +### 0.9.0 +* Adding new `feedback` option to override the classes used for feedback icons (#97) +* Exposing selector used to determine which inputs to validate as `Validator.INPUT_SELECTOR` +* Removing inline styles on submit button no longer needed in Bootstrap v3.3.5 (#166) +* Add `jquery >= 1.8.3` to bower.json (#160) + +###### Docs Changes +* Upgrade to Bootstrap v3.3.5 +* Added a form-feedback example to the docs +* Added a custom validator server example to the docs + ### 0.8.1 * No longer running validators on button elements. Fixes #93. * No longer running validators on invisible input elements. Fixes #65. -* Adding support for button[form="myForm"]. Fixes #74. +* Adding support for `button[form="myForm"]`. Fixes #74. ### 0.8.0 * Adding custom validators option. -* Only adding .has-success class if there is a .form-control-feedback present. +* Only adding .has-success class if there is a `.form-control-feedback` present. ### 0.7.3 * No longer validating `input[type="hidden"]` fields. Fixes #84. diff --git a/_config.yml b/_config.yml index d8b25ef..824225e 100644 --- a/_config.yml +++ b/_config.yml @@ -13,5 +13,5 @@ baseurl: / encoding: UTF-8 repo: https://github.com/1000hz/bootstrap-validator -cdn_bootstrap_css: //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css -cdn_bootstrap_js: //netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js \ No newline at end of file +cdn_bootstrap_css: //netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css +cdn_bootstrap_js: //netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js \ No newline at end of file diff --git a/bower.json b/bower.json index f7469f3..ddd6992 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-validator", - "version": "0.8.1", + "version": "0.9.0", "homepage": "https://github.com/1000hz/bootstrap-validator", "authors": [ "Cina Saffary " @@ -26,5 +26,8 @@ "Gruntfile.js", "package.json", "*.html" - ] + ], + "dependencies": { + "jquery": ">= 1.8.3" + } } diff --git a/dist/validator.js b/dist/validator.js index 030b00d..5edcd23 100644 --- a/dist/validator.js +++ b/dist/validator.js @@ -1,5 +1,5 @@ /*! - * Validator v0.8.1 for Bootstrap 3, by @1000hz + * Validator v0.9.0 for Bootstrap 3, by @1000hz * Copyright 2015 Cina Saffary * Licensed under http://opensource.org/licenses/MIT * @@ -9,7 +9,6 @@ +function ($) { 'use strict'; - var inputSelector = ':input:not([type="submit"], button):enabled:visible' // VALIDATOR CLASS DEFINITION // ========================== @@ -41,6 +40,8 @@ }) } + Validator.INPUT_SELECTOR = ':input:not([type="submit"], button):enabled:visible' + Validator.DEFAULTS = { delay: 500, html: false, @@ -52,20 +53,20 @@ }, feedback: { success: 'glyphicon-ok', - error: 'glyphicon-warning-sign' + error: 'glyphicon-remove' } } Validator.VALIDATORS = { - native: function ($el) { + 'native': function ($el) { var el = $el[0] return el.checkValidity ? el.checkValidity() : true }, - match: function ($el) { + 'match': function ($el) { var target = $el.data('match') return !$el.val() || $el.val() === $(target).val() }, - minlength: function ($el) { + 'minlength': function ($el) { var minlength = $el.data('minlength') return !$el.val() || $el.val().length >= minlength } @@ -143,7 +144,7 @@ var delay = this.options.delay this.options.delay = 0 - this.$element.find(inputSelector).trigger('input.bs.validator') + this.$element.find(Validator.INPUT_SELECTOR).trigger('input.bs.validator') this.options.delay = delay return this @@ -194,7 +195,7 @@ return !!($(this).data('bs.validator.errors') || []).length } - return !!this.$element.find(inputSelector).filter(fieldErrors).length + return !!this.$element.find(Validator.INPUT_SELECTOR).filter(fieldErrors).length } Validator.prototype.isIncomplete = function () { @@ -204,7 +205,7 @@ $.trim(this.value) === '' } - return !!this.$element.find(inputSelector).filter('[required]').filter(fieldIncomplete).length + return !!this.$element.find(Validator.INPUT_SELECTOR).filter('[required]').filter(fieldIncomplete).length } Validator.prototype.onSubmit = function (e) { @@ -214,11 +215,18 @@ Validator.prototype.toggleSubmit = function () { if(!this.options.disable) return +<<<<<<< HEAD var $btn = $('button[type="submit"], [data-validator="submit"], input[type="submit"]') .filter('[form="' + this.$element.attr('id') + '"]') .add(this.$element.find('input[type="submit"], button[type="submit"], [data-validator="submit"]')) +======= + + var $btn = $('button[type="submit"], input[type="submit"]') + .filter('[form="' + this.$element.attr('id') + '"]') + .add(this.$element.find('input[type="submit"], button[type="submit"]')) + +>>>>>>> 1000hz/master $btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors()) - .css({'pointer-events': 'all', 'cursor': 'pointer'}) } Validator.prototype.defer = function ($el, callback) { @@ -234,7 +242,7 @@ .removeData('bs.validator') .off('.bs.validator') - this.$element.find(inputSelector) + this.$element.find(Validator.INPUT_SELECTOR) .off('.bs.validator') .removeData(['bs.validator.errors', 'bs.validator.deferred']) .each(function () { diff --git a/dist/validator.min.js b/dist/validator.min.js index b42c8f8..ecd5705 100644 --- a/dist/validator.min.js +++ b/dist/validator.min.js @@ -1,9 +1,13 @@ /*! - * Validator v0.8.1 for Bootstrap 3, by @1000hz + * Validator v0.9.0 for Bootstrap 3, by @1000hz * Copyright 2015 Cina Saffary * Licensed under http://opensource.org/licenses/MIT * * https://github.com/1000hz/bootstrap-validator */ -+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b),f=c.data("bs.validator");(f||"destroy"!=b)&&(f||c.data("bs.validator",f=new d(this,e)),"string"==typeof b&&f[b]())})}var c=':input:not([type="submit"], button):enabled:visible',d=function(b,c){this.$element=a(b),this.options=c,c.errors=a.extend({},d.DEFAULTS.errors,c.errors);for(var e in c.custom)if(!c.errors[e])throw new Error("Missing default error message for custom validator: "+e);a.extend(d.VALIDATORS,c.custom),this.$element.attr("novalidate",!0),this.toggleSubmit(),this.$element.on("input.bs.validator change.bs.validator focusout.bs.validator",a.proxy(this.validateInput,this)),this.$element.on("submit.bs.validator",a.proxy(this.onSubmit,this)),this.$element.find("[data-match]").each(function(){var b=a(this),c=b.data("match");a(c).on("input.bs.validator",function(){b.val()&&b.trigger("input.bs.validator")})})};d.DEFAULTS={delay:500,html:!1,disable:!0,custom:{},errors:{match:"Does not match",minlength:"Not long enough"},feedback:{success:"glyphicon-ok",error:"glyphicon-warning-sign"}},d.VALIDATORS={"native":function(a){var b=a[0];return b.checkValidity?b.checkValidity():!0},match:function(b){var c=b.data("match");return!b.val()||b.val()===a(c).val()},minlength:function(a){var b=a.data("minlength");return!a.val()||a.val().length>=b}},d.prototype.validateInput=function(b){var c=a(b.target),d=c.data("bs.validator.errors");if(c.is('[type="radio"]')&&(c=this.$element.find('input[name="'+c.attr("name")+'"]')),this.$element.trigger(b=a.Event("validate.bs.validator",{relatedTarget:c[0]})),!b.isDefaultPrevented()){var e=this;this.runValidators(c).done(function(f){c.data("bs.validator.errors",f),f.length?e.showErrors(c):e.clearErrors(c),d&&f.toString()===d.toString()||(b=f.length?a.Event("invalid.bs.validator",{relatedTarget:c[0],detail:f}):a.Event("valid.bs.validator",{relatedTarget:c[0],detail:d}),e.$element.trigger(b)),e.toggleSubmit(),e.$element.trigger(a.Event("validated.bs.validator",{relatedTarget:c[0]}))})}},d.prototype.runValidators=function(b){function c(a){return b.data(a+"-error")||b.data("error")||"native"==a&&b[0].validationMessage||g.errors[a]}var e=[],f=a.Deferred(),g=this.options;return b.data("bs.validator.deferred")&&b.data("bs.validator.deferred").reject(),b.data("bs.validator.deferred",f),a.each(d.VALIDATORS,a.proxy(function(a,d){if((b.data(a)||"native"==a)&&!d.call(this,b)){var f=c(a);!~e.indexOf(f)&&e.push(f)}},this)),!e.length&&b.val()&&b.data("remote")?this.defer(b,function(){var d={};d[b.attr("name")]=b.val(),a.get(b.data("remote"),d).fail(function(a,b,d){e.push(c("remote")||d)}).always(function(){f.resolve(e)})}):f.resolve(e),f.promise()},d.prototype.validate=function(){var a=this.options.delay;return this.options.delay=0,this.$element.find(c).trigger("input.bs.validator"),this.options.delay=a,this},d.prototype.showErrors=function(b){var c=this.options.html?"html":"text";this.defer(b,function(){var d=b.closest(".form-group"),e=d.find(".help-block.with-errors"),f=d.find(".form-control-feedback"),g=b.data("bs.validator.errors");g.length&&(g=a("