I am currently working on a annual violation validation form that has a data table that the driver will input their driving violations for the year. The functionality will go as below:
- Column 1 Date of violation *Required
- Column 2 Violation type *Required
- Column 3 If "Other" is selected on Column 2 then this field needs a value otherwise not. I'd like it read only and go to required if Other is selected but I can't get that to work for the life of me so at minimum I am checking for a value.
- Column 4 Location *Required.
I have the start of the JavaScript that is only partially working. (Pasted below) Any help is appreciated.
fd.control('ViolationTable').addValidator({
name: 'DataTable validator',
error: "You selected OTHER on a violation and didn't put in a value.",
validate: function(value){
for(var i = 0; i < value.length; i++){
if(value[i].Violation == 'Other (Type in next field)' && !value[i].Other){
return false;
}
}
fd.control('ViolationTable').addValidator({
name: 'DataTable validator',
error: "Missing a location on a record.",
validate: function(value){
for(var i = 0; i < value.length; i++){
if(!value[i].Location){
return false;
}
}
return true;
}});
}});