From b493f1350494abaa7e7499052e8aa2f3dfde83b9 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 8 Dec 2014 16:38:09 -0500 Subject: [PATCH] Adds #1396, Adds optional parameter to form validation --- src/definitions/behaviors/form.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 701421cae..dc2572d8c 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -398,7 +398,11 @@ $.fn.form = function(fields, parameters) { fieldValid = true, fieldErrors = [] ; - if(field.rules !== undefined) { + if(field.optional && $.trim($field.val()) === ''){ + module.debug('Field is optional and empty. Skipping', field.identifier); + fieldValid = true; + } + else if(field.rules !== undefined) { $.each(field.rules, function(index, rule) { if( module.has.field(field.identifier) && !( module.validate.rule(field, rule) ) ) { module.debug('Field is invalid', field.identifier, rule.type); @@ -643,7 +647,7 @@ $.fn.form.settings = { revalidate : true, transition : 'scale', - duration : 150, + duration : 200, onValid : function() {}, @@ -669,15 +673,13 @@ $.fn.form.settings = { error : 'error', success : 'success', down : 'down', - label : 'ui label prompt' + label : 'ui prompt label' }, - // errors error: { method : 'The method you called is not defined.' }, - templates: { error: function(errors) { var