Skip to main content

Bug Tracker

Side navigation

Ticket #3370: jquery_validate_ignoretitle.patch


File jquery_validate_ignoretitle.patch, 2.1 KB (added by orip, September 15, 2008 04:42PM UTC)

patch for ignoreTitle implementation + tests

Index: test/test.js
===================================================================
--- test/test.js	(revision 5844)
+++ test/test.js	(working copy)
@@ -596,6 +596,18 @@
 	equals("", $("#firstname").val(), "form plugin is included, therefor resetForm must also reset inputs, not only errors");
 });
 
+test("message from title", function() {
+	var v = $("#withTitle").validate();
+    v.checkForm();
+	equals(v.errorList[0].message, "fromtitle", "title not used");
+});
+
+test("ignoreTitle", function() {
+	var v = $("#withTitle").validate({ignoreTitle:true});
+    v.checkForm();
+	equals(v.errorList[0].message, $.validator.messages["required"], "title used when it should have been ignored");
+});
+
 test("ajaxSubmit", function() {
 	expect(1);
 	stop();
@@ -1084,4 +1096,4 @@
 	e.val("asdf");
 	ok( !v.element(e), "still invalid, because remote validation must block until it returns" );
 });
-*/
\ No newline at end of file
+*/
Index: test/index.html
===================================================================
--- test/index.html	(revision 5844)
+++ test/index.html	(working copy)
@@ -245,6 +245,10 @@
 			
+ +
+ +
    Index: jquery.validate.js =================================================================== --- jquery.validate.js (revision 5844) +++ jquery.validate.js (working copy) @@ -198,6 +198,7 @@ errorLabelContainer: $( [] ), onsubmit: true, ignore: [], + ignoreTitle: false, onfocusin: function(element) { this.lastActive = element; @@ -530,7 +531,7 @@ this.customMessage( element.name, method ), this.customMetaMessage( element, method ), // title is never undefined, so handle empty string as undefined - element.title || undefined, + this.settings.ignoreTitle ? undefined : (element.title || undefined), $.validator.messages[method], "Warning: No message defined for " + element.name + "" );

    Download in other formats:

    Original Format