Skip to content

Commit

Permalink
Now possible to use callback in errorMessagePosition, issue #226
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjonsson committed Nov 29, 2015
1 parent b9d8a67 commit fa4e146
Show file tree
Hide file tree
Showing 47 changed files with 72 additions and 57 deletions.
2 changes: 1 addition & 1 deletion form-validator/brazil.dev.js
Expand Up @@ -11,7 +11,7 @@
*
* @website http://formvalidator.net/#brazil-validators
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/

$.formUtils.addValidator({
Expand Down
2 changes: 1 addition & 1 deletion form-validator/brazil.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/date.dev.js
Expand Up @@ -10,7 +10,7 @@
*
* @website http://formvalidator.net/#location-validators
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function($) {

Expand Down
2 changes: 1 addition & 1 deletion form-validator/date.js
Expand Up @@ -3,6 +3,6 @@
*
* @website by
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
!function(a){a.formUtils.addValidator({name:"time",validatorFunction:function(a){if(null===a.match(/^(\d{2}):(\d{2})$/))return!1;var b=parseInt(a.split(":")[0],10),c=parseInt(a.split(":")[1],10);return b>23||c>59?!1:!0},errorMessage:"",errorMessageKey:"badTime"}),a.formUtils.addValidator({name:"birthdate",validatorFunction:function(b,c,d){var e="yyyy-mm-dd";c.valAttr("format")?e=c.valAttr("format"):"undefined"!=typeof d.dateFormat&&(e=d.dateFormat);var f=a.formUtils.parseDate(b,e);if(!f)return!1;var g=new Date,h=g.getFullYear(),i=f[0],j=f[1],k=f[2];if(i===h){var l=g.getMonth()+1;if(j===l){var m=g.getDate();return m>=k}return l>j}return h>i&&i>h-124},errorMessage:"",errorMessageKey:"badDate"})}(jQuery);
2 changes: 1 addition & 1 deletion form-validator/file.dev.js
Expand Up @@ -10,7 +10,7 @@
*
* @website http://formvalidator.net/#file-validators
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function($, window) {

Expand Down
2 changes: 1 addition & 1 deletion form-validator/file.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/html5.dev.js
Expand Up @@ -17,7 +17,7 @@
*
* @website http://formvalidator.net/
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function($, window) {

Expand Down
2 changes: 1 addition & 1 deletion form-validator/html5.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 21 additions & 9 deletions form-validator/jquery.form-validator.js
Expand Up @@ -5,7 +5,7 @@
*
* @website http://formvalidator.net/
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function ($) {

Expand Down Expand Up @@ -66,9 +66,13 @@
$mess = {};

if (custom) {
setErrorMessage($(custom));
_warn('Using deprecated element reference '+custom.id);
$messageContainer = $(custom);
} else if( typeof $messageContainer === 'function' ) {
$messageContainer = $messageContainer($input, mess, conf);
}
else if (typeof $messageContainer === 'object') {

if (typeof $messageContainer === 'object') {
var $found = false;
$messageContainer.find('.' + conf.errorMessageClass).each(function () {
if (this.inputReferer === $input[0]) {
Expand Down Expand Up @@ -101,6 +105,17 @@
setErrorMessage($mess);
}
},
_warn = function(msg) {
if( 'console' in window ) {
if( typeof window.console.warn === 'function' ) {
window.console.warn(msg);
} else if( typeof window.console.log === 'function' ) {
window.console.log(msg);
}
} else {
alert(msg);
}
},
_templateMessage = function ($form, title, errorMessages, conf) {
var messages = conf.errorMessageTemplate.messages.replace(/\{errorTitle\}/g, title),
fields = [],
Expand Down Expand Up @@ -490,6 +505,7 @@
}
// Customize display message
else if (conf.errorMessagePosition === 'custom') {
_warn('Use deprecated function errorMessageCustom');
if (typeof conf.errorMessageCustom === 'function') {
conf.errorMessageCustom($form, language.errorTitle, errorMessages, conf);
}
Expand Down Expand Up @@ -522,9 +538,7 @@
* @param conf
*/
$.fn.validateForm = function (language, conf) {
if (window.console && typeof window.console.warn === 'function') {
window.console.warn('Use of deprecated function $.validateForm, use $.isValid instead');
}
_warn('Use of deprecated function $.validateForm, use $.isValid instead');
return this.isValid(language, conf, true);
};

Expand Down Expand Up @@ -877,9 +891,7 @@
script.onload = moduleLoadedCallback;
script.src = scriptUrl + ( scriptUrl.slice(-7) === '.dev.js' ? cacheSuffix : '' );
script.onerror = function() {
if( 'console' in window && window.console.log ) {
window.console.log('Unable to load form validation module '+scriptUrl);
}
_warn('Unable to load form validation module '+scriptUrl);
};
script.onreadystatechange = function () {
// IE 7 fix
Expand Down
4 changes: 2 additions & 2 deletions form-validator/jquery.form-validator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion form-validator/jsconf.dev.js
Expand Up @@ -7,7 +7,7 @@
*
* @website http://formvalidator.net/#location-validators
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function($) {

Expand Down
2 changes: 1 addition & 1 deletion form-validator/jsconf.js
Expand Up @@ -3,6 +3,6 @@
*
* @website by
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
!function(a){"use strict";a.setupValidation=function(b){var c=a(b.form||"form");a.each(b.validate||b.validation||{},function(b,d){var e;e="#"===b[0]?a(b):c.find("."===b[0]?b:'*[name="'+b+'"]'),e.attr("data-validation",d.validation),a.each(d,function(a,b){"validation"!==a&&b!==!1&&(b===!0&&(b="true"),e.valAttr(a,b))})}),a.validate(b)}}(jQuery);
2 changes: 1 addition & 1 deletion form-validator/lang/cz.dev.js
Expand Up @@ -6,7 +6,7 @@
*
* @website http://formvalidator.net/
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function($, window) {

Expand Down
2 changes: 1 addition & 1 deletion form-validator/lang/cz.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/de.dev.js
Expand Up @@ -6,7 +6,7 @@
*
* @website http://formvalidator.net/
* @license MIT
* @version 2.2.87
* @version 2.2.88
*/
(function($, window) {

Expand Down
2 changes: 1 addition & 1 deletion form-validator/lang/de.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion form-validator/lang/es.dev.js
Expand Up @@ -6,7 +6,7 @@
*
* @website http://formvalidator.net/
* @license Dual licensed under the MIT or GPL Version 2 licenses
* @version 2.2.87
* @version 2.2.88
*/
(function($, window) {

Expand Down

0 comments on commit fa4e146

Please sign in to comment.