diff --git a/index.html b/index.html index 40269c5..34a5354 100644 --- a/index.html +++ b/index.html @@ -25,8 +25,7 @@ $(this).formvalidate({ onSuccess: function(O) { alert('Form #1 is valid!'); - }, - language: 'de' + } }); }); @@ -36,19 +35,32 @@ // From the anchor element find the closest form element $(this).closest('form').formvalidate({ + // Add a custom validation method error message + localization: { + en: { + name: 'Your {0} cannot be "{2}" because this is a custom validation method and I said so.' + } + }, validations: { - /** - * Add a custom validation - * - * @todo 'Your {0} cannot be "{2}" because this is a custom validation method and I said so.' - */ - middle_name: function(input, params) { + // Add a custom validation method + name: function(input, params) { return input.toLowerCase() === params[0].toLowerCase() ? false : true; } } }); }); + // Validate on form submission + $('#form_3').submit(function(e) { + e.preventDefault(); + $(this).formvalidate({ + onSuccess: function(O) { + alert('Sehr Gut!'); + }, + language: 'de' + }); + }); + // Toggle "Why So Cool?" (function () { var cool = $('input[name="cool"]'); @@ -188,8 +200,7 @@