EqualTo using incorrect method name for jquery.validate.js

499 views
Skip to first unread message

Jason Durham

unread,
May 25, 2013, 7:49:53 PM5/25/13
to valida...@googlegroups.com

Line 24 of this file is causing a value of "equalto" be returned to the client for validation.  The method name needs to be "equalTo" if the intent is to use the method provided jquery.validate.js.

Snippet of rules returned to client:
-----------------------------------------------------
verifyEmailAddress: 
{
   equalto":input[name='emailAddress']",
   required{
      DependentInputName"",
      DependentInputValue"",
      DependentInputDesc""
   },
   emailtrue
},
emailAddress: 
{
   required
{
      DependentInputName"",
      DependentInputValue"",
      DependentInputDesc""
   },
   emailtrue
}


From my browser's console:
-----------------------------------------------------
Uncaught TypeError: Cannot call method 'call' of undefined



Referencing Line 530 of jquery.validate.this:
-----------------------------------------------------
result = $.validator.methods[method].call( this, val, element, rule.parameters );
Uncaught TypeError: Cannot call method 'call' of undefined (repeated 2 times)
Uncaught TypeError: Cannot call method 'call' of undefined


Jason Durham

John Whish

unread,
May 26, 2013, 5:46:08 AM5/26/13
to valida...@googlegroups.com

Interesting. Which version of the validate plugin and jquery are you using?

Thanks

--
You received this message because you are subscribed to the Google Groups "ValidateThis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to validatethis...@googlegroups.com.
To post to this group, send email to valida...@googlegroups.com.
Visit this group at http://groups.google.com/group/validatethis?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jason Durham

unread,
May 26, 2013, 5:19:54 PM5/26/13
to valida...@googlegroups.com, john....@googlemail.com
I'm using the latest from the development branch (just DL'd yesterday while debugging this).  I'm using jQuery v1.9.1.

Chip Pinkston

unread,
Apr 24, 2014, 11:24:25 AM4/24/14
to valida...@googlegroups.com
Just a quick follow up - I've been running into this issue.  I ended up duplicating the code for 'equalTo' as 'equalto' in the  jquery.validate.min.js (latest from github master) file to get the client side validation for my forms to work properly.  Not the ideal solution, but had to get something out the door.

Entry from my Rule file:
{"name":"email","desc":"Email Address",
"rules": [
{"type":"required","failureMessage":"Email Address is required"},
{"type":"email","failureMessage":"Please enter a valid Email Address"}
]
},
{"name":"confirmemail","desc":"Confirm Email",
"rules": [
{"type":"required","failureMessage":"Confirmation Email Address is required"},
{"type":"equalTo",
"params" : [
{"name":"ComparePropertyName","value":"email"}
]
,"failureMessage":"Confirmation Email Address must match Email Address"
}
]
},

Generated Output:
fm['confirmemail'] = $(":input[name='confirmemail']",$form_formstep1);
if(fm['confirmemail'].length){
fm['confirmemail'].rules("add",{
required:true
,messages:{
required:"Confirmation Email Address is required"
}
});
}
fm['confirmemail'] = $(":input[name='confirmemail']",$form_formstep1);
if(fm['confirmemail'].length){
fm['confirmemail'].rules('add',{
"equalto":":input[name='email']","messages":{
"equalto":"Confirmation Email Address must match Email Address"
}
});
}

Removed the lcase from AbstractClientRuleScripter.cfc:
  if(fm['confirmemail'].length){
fm['confirmemail'].rules('add',{
"EqualTo":":input[name='email']","messages":{
"EqualTo":"Confirmation Email Address must match Email Address"
}
});
}

Final Entries in my  jquery.validate.min.js (green original, yellow new)

            equalTo: "Please enter the same value again.",
            equalto: "Please enter the same value again.",


            equalTo: function (a, b, d) {
                d = c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo", function () {
                    c(b).valid()
                });
                return a == d.val()
            },   
            equalto: function (a, b, d) {
                d = c(d).unbind(".validate-equalto").bind("blur.validate-equalto", function () {
                    c(b).valid()
                });
                return a == d.val()
            }


Hope this helps someone else.

Chip.
Reply all
Reply to author
Forward
0 new messages