diff --git a/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs b/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs index 899c05a..9b5508c 100644 --- a/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs +++ b/src/ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider/Properties/AssemblyInfo.cs @@ -30,5 +30,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2.3.0")] -[assembly: AssemblyFileVersion("2.2.3.0")] +[assembly: AssemblyVersion("2.2.4.0")] +[assembly: AssemblyFileVersion("2.2.4.0")] diff --git a/src/ExpressiveAnnotations.MvcWebSample/Views/Home/Home.cshtml b/src/ExpressiveAnnotations.MvcWebSample/Views/Home/Home.cshtml index 8073378..daee4a3 100644 --- a/src/ExpressiveAnnotations.MvcWebSample/Views/Home/Home.cshtml +++ b/src/ExpressiveAnnotations.MvcWebSample/Views/Home/Home.cshtml @@ -43,6 +43,8 @@ // expann.addMethod... // do something with ExpressiveAnnotations // ea... // do something with original ea variable + // ea.settings.dependencyTriggers = 'change'; // disable some excessive activity if you wish, and e.g. trigger dependent fields validation only when field "change" event is fired + @if ("pl" == lang) { diff --git a/src/expressive.annotations.validate.js b/src/expressive.annotations.validate.js index 10cefed..242f159 100644 --- a/src/expressive.annotations.validate.js +++ b/src/expressive.annotations.validate.js @@ -1,4 +1,4 @@ -/* expressive.annotations.validate.js - v2.3.0 +/* expressive.annotations.validate.js - v2.4.0 * Client-side component of ExpresiveAnnotations - annotation-based conditional validation library. * https://github.com/JaroslawWaliszko/ExpressiveAnnotations * @@ -10,9 +10,11 @@ var backup = window.ea, // map over the ea in case of overwrite api = { // to be accesssed from outer scope - settings: { - parseObject: undefined, // if you'd like to represent a fields data in any other form than a default json (not recommended), it is the place for any custom deserializer - parseDate: undefined // provide implementation to parse date in non-standard format + settings: { + dependencyTriggers: 'change paste keyup', // a string containing one or more DOM field event types (such as "change", "keyup" or custom event names) + // for which fields directly dependent on referenced DOM field are validated + parseObject: undefined, // provide custom deserialization for objects when stored in non-json format + parseDate: undefined // provide custom parsing mechanism for dates when stored in non-standard format // e.g., suppose DOM field date is given in dd/mm/yyyy format: // parseDate = function(str) { // input string is given as a raw value extracted from DOM element // var arr = str.split('/'); return new Date(arr[2], arr[1] - 1, arr[0]).getTime(); // return milliseconds since January 1, 1970, 00:00:00 UTC @@ -385,7 +387,7 @@ var if (referencedFields !== undefined && referencedFields !== null) { i = referencedFields.length; while (i--) { - field = $(form).find(':input[name="' + referencedFields[i] + '"]'); + field = $(form).find(':input[data-val][name="' + referencedFields[i] + '"]'); if (field.length !== 0) { field.valid(); } @@ -393,9 +395,9 @@ var } }, binded: false, - bindAction: function(form) { + bindFields: function(form) { if (!this.binded) { - $(form).find('input, select, textarea').bind('change paste keyup', function() { + $(form).find('input, select, textarea').bind(api.settings.dependencyTriggers, function() { var field = $(this).attr('name'); validationHelper.validateReferences(field, form); // validate referenced fields only }); @@ -420,7 +422,7 @@ var options.messages[adapter] = options.message; } var rules = options.rules[adapter]; - validationHelper.bindAction(options.form); + validationHelper.bindFields(options.form); validationHelper.collectReferences(typeHelper.object.keys(rules.fieldsMap), options.element.name, rules.prefix); }); }); @@ -440,7 +442,7 @@ var options.messages[adapter] = options.message; } var rules = options.rules[adapter]; - validationHelper.bindAction(options.form); + validationHelper.bindFields(options.form); validationHelper.collectReferences(typeHelper.object.keys(rules.fieldsMap), options.element.name, rules.prefix); }); });