Mar 7th, 2010, 11:11 PM
The problem is here:
The custom validation gets the fieldname to validate from the second value of each rule (var fieldName = parts[1]; ) And if you look at the code below, the second value is the same for both rootpassword, and rootpassword2. The correct field would be rootpassword2 (marked in green below).
var myRules = [
"required,rootpassword,Password Required",
"same_as,rootpassword,rootpassword2,Password Must Match"
];
var parts = myRules[i].split(",");
var fieldName = parts[1];
Since the same_as function gets which field to match against from the variable placed right after it, after the comma (marked in red above), your example becomes flawed. The rule for the same_as line above will never return an error message for rootpassword2.
I think you have a great script, but I never got it to do what I wanted due to this issue. So I abandoned it. I'd love to use it, if the custom example is fixed
Thanks!
The custom validation gets the fieldname to validate from the second value of each rule (var fieldName = parts[1]; ) And if you look at the code below, the second value is the same for both rootpassword, and rootpassword2. The correct field would be rootpassword2 (marked in green below).
var myRules = [
"required,rootpassword,Password Required",
"same_as,rootpassword,rootpassword2,Password Must Match"
];
var parts = myRules[i].split(",");
var fieldName = parts[1];
Since the same_as function gets which field to match against from the variable placed right after it, after the comma (marked in red above), your example becomes flawed. The rule for the same_as line above will never return an error message for rootpassword2.
I think you have a great script, but I never got it to do what I wanted due to this issue. So I abandoned it. I'd love to use it, if the custom example is fixed

Thanks!
(Mar 7th, 2010, 7:27 PM)Ben Wrote: Hey perfectpixel,
I'm sorry, I guess I'm just not following your explanation of the problem... Martin, if I'm being totally daft, do chime in.
Quote:As such, the second value in the same_as rule is the same as the field to match against.
No, I don't think so... the same_as rule works properly. I've actually used it for several years now and it still appears to be working fine.
Sorry for not following! Could you maybe post a link to the form so I could look at it directly?
- Ben