The title sucks, I’m sorry.
It takes a little bit to setup my problem, so I’m going to try and simplify it.
My form uses structure notation.
<input type= "text"
name= "bank[routing_number]"
id= "bank_routing_number"
value= "#rc.bank[ "routing_number" ]#"
autocomplete= "off"
maxlength= "9" />
<input type= "text"
name= "bank[routing_number_confirmation]"
id= "bank_routing_number_confirmation"
value= "#rc.bank[ "routing_number_confirmation" ]#"
autocomplete= "off"
maxlength= "9" />
The ValidateThis rules work fine on the server. I’m running on ColdFusion 9.0.1.
The problem I have is the JavaScript code generated by ValidateThis.
This is the JavaScript rule for EqualTo.
fm['bank[routing_number_confirmation]'].rules('add',{"equalto":":input[name='routing_number']","messages":{"equalto":"Bank ACH Routing Numbers (ABA) must match."}}); fm['bank[routing_number_confirmation]'] = $(":input[name='bank[routing_number_confirmation]']",$form_register_new);
The relative bit is this:
":input[name='routing_number']"
I’m expecting this code to be:
":input[name='bank[routing_number]']"
Here are the ValidateThis rules for routing_number and routing_number_confirmation.
{ "name": "routing_number" ,
"clientFieldName": "bank[routing_number]" ,
"rules": [
{ "type": "required" ,
"failureMessage": "Bank ACH Routing Number (ABA) is required."
} ,
{ "type": "rangelength" ,
"params": [
{ "name": "minlength" , "value": "9" } ,
{ "name": "maxlength" , "value": "9"} ] ,
"failureMessage": "Bank ACH Routing Number (ABA) is 9 digits."
}
]
} ,
{ "name": "routing_number_confirmation" ,
"clientFieldName": "bank[routing_number_confirmation]" ,
"rules": [
{ "type": "required" ,
"failureMessage": "Confirm Bank ACH Routing Number (ABA) is required."
} ,
{ "type": "equalTo" ,
"params": [
{ "name": "comparePropertyName" ,
"value": "routing_number" }
] ,
"failureMessage": "Bank ACH Routing Numbers (ABA) must match."
} ,
{ "type": "rangelength" ,
"params": [
{ "name": "minlength" , "value": "9" } ,
{ "name": "maxlength" , "value": "9"} ] ,
"failureMessage": "Bank ACH Routing Number (ABA) is 9 digits."
}
]
}
This is the load order for ValidateThis scripts.
// jQuery and jQuery Validate are loaded.
#getColdboxOCM().get( "ValidateThis" ).getInitializationScript(
JSIncludes= false )#
// Other ValidateThis scripts
#getColdboxOCM().get( "ValidateThis" ).getValidationScript(
objectType= "registration/bank-account" ,
formName= rc.form.name )#
The other JavaScript rules for routing_number and routing_number_confirmation work just fine. I’ve added some custom rules to get around the issue, but is there a way I can fix this using ValidateThis?
I asked the question on the ValidateThis Google Group and got a prompt response.
http://groups.google.com/group/validatethis/browse_thread/thread/2b18af00d3f5ce98
This was a bug within ValidateThis, but was corrected and is now part of the development branch in github.