Ok, there may be another way, but here's the way I did it.
* I actually used condition because I needed to pass in 3 fields. * Then for message: I just put "". This resets the message, otherwise, it stays on the last one displayed.
* Then, in my function, I set the Validator fields using the location of the validator for the function I'm using. Here's an example:
// The End Date cannot be before the Start Date and, if the employeeType selection is Researcher, there must be a date entered in the End Date field
function researcherFunction(radioObj, end, start){
if (end != "") {
if(new Date(end) < new Date(start)){
Validator.fields[15].message = "The End Date must be greater than the Start Date";
}
}
else if(radioObj){
var radioLength = radioObj.length;
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
var selected = radioObj[i].value;
if((selected == "Researcher") && (end == "")){
Validator.fields[15].message = "You must select an End Date for a 'Researcher' Employee Type";
I figured it out!
Ok, there may be another way, but here's the way I did it.
* I actually used condition because I needed to pass in 3 fields. * Then for message: I just put "". This resets the message, otherwise, it stays on the last one displayed.
* Then, in my function, I set the Validator fields using the location of the validator for the function I'm using. Here's an example:
// The End Date cannot be before the Start Date and, if the employeeType selection is Researcher, there must be a date entered in the End Date field
function researcherFunction(radioObj, end, start){
if (end != "") {
if(new Date(end) < new Date(start)){
Validator.fields[15].message = "The End Date must be greater than the Start Date";
}
}
else if(radioObj){
var radioLength = radioObj.length;
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
var selected = radioObj[i].value;
if((selected == "Researcher") && (end == "")){
Validator.fields[15].message = "You must select an End Date for a 'Researcher' Employee Type";
}
else{
return true;
}
}
}
}
else {
return true;
}
}