标题太糟糕了,对不起。
设置我的问题需要一点点,所以我将尝试简化它。
我的表单使用结构表示法。
<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" />
ValidateThis规则在服务器上正常工作。我正在运行ColdFusion 9.0.1。
我遇到的问题是ValidateThis生成的JavaScript代码。
这是EqualTo的JavaScript规则。
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);
相对位是:
":input[name='routing_number']"
我期待这段代码:
":input[name='bank[routing_number]']"
以下是routing_number和routing_number_confirmation的ValidateThis规则。
{ "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."
}
]
}
这是ValidateThis脚本的加载顺序。
// 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 )#
routing_number和routing_number_confirmation的其他JavaScript规则工作得很好。我已经添加了一些自定义规则来解决这个问题,但有没有办法可以使用ValidateThis解决这个问题?
答案 0 :(得分:0)
我在ValidateThis Google Group上提出了问题并得到了及时响应。
http://groups.google.com/group/validatethis/browse_thread/thread/2b18af00d3f5ce98
这是ValidateThis中的一个错误,但已得到纠正,现在是github中开发分支的一部分。