From d8fdfdd4a2c5d265cdc6b0ee1367286d6091182a Mon Sep 17 00:00:00 2001 From: vmichnowicz Date: Mon, 13 Feb 2012 20:11:58 -0500 Subject: [PATCH] Update example code & add new example --- index.html | 73 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 13 deletions(-) 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 @@

Example Form Number One Code

$(this).formvalidate({ onSuccess: function(O) { alert('Form #1 is valid!'); - }, - language: 'de' + } }); }); @@ -201,7 +212,7 @@

Example Form Number One Code

Example Form Number Two Code

- +
@@ -266,9 +277,15 @@

Example Form Number Two Code

// 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 - middle_name: function(input, params) { + // Add a custom validation method + name: function(input, params) { return input.toLowerCase() === params[0].toLowerCase() ? false : true; } } @@ -276,6 +293,36 @@

Example Form Number Two Code

}); + +
+
+ Example Form Number Three (German) +

Example Form Number Three (German) Code

+
+ + +
+
+ + +
+
+ +
+
+// Validate on form submission
+$('#form_3').submit(function(e) {
+	e.preventDefault();
+	$(this).formvalidate({
+		onSuccess: function(O) {
+			alert('Sehr Gut!');
+		},
+		language: 'de'
+	});
+});
+
+
+