Validation Toolkit Required Field Error
Hello,
I had an error when trying to apply a Required/Not Blank/Selection Made validation to a text field or any other tag. After taking a look at the code that generated the error (Line 43 on WAFV_Required_C.js file) -> error: tagType undefined.
I managed to make the validation work by adding a line of code to this function on the file:
function applyBehavior() {
var theReference = "";
if (!isCommand) {
theReference = document.theForm.formElement.options[document.theForm.formElement.selectedIndex].text
}
else {
theReference = theElement;
}
var theForm = theReference.substring(0,theReference.indexOf("."));
var theField = theReference.substring(theReference.indexOf(".")+1);
theValue = "document.getElementById('" + theForm +"')."+theField;
setID(theForm);
var tagType = theElementType; //Added this line of code
if (tagType.toLowerCase()!="select" && tagType.toLowerCase()!="checkbox" && tagType.toLowerCase()!="radio") {
var theValue = theValue + ".value";
}
var errorMsg = encodeAlert(document.theForm.errorMSG.value);
var stopIt = getRadioVal(document.theForm.ErrorResult);
var trimWhite = !document.theForm.trimCHK.checked;
var theFocus = false;
if (isCommand) {
if (theElementType != "input.hidden") {
theFocus = theValue;
}
if (theElementType == "radio") {
theFocus += "[0]";
}
}
else if (document.theForm.formElement.options[document.theForm.formElement.selectedIndex].value == "true") {
theFocus = "document." + document.theForm.formElement.options[document.theForm.formElement.selectedIndex].text;
if (tagType == "radio")
theFocus += "[0]";
}
if (isCommand) {
return "WAValidateRQ("+"document." + theElement +",'"+errorMsg+"',"+theFocus+","+stopIt+","+trimWhite+",'"+tagType+"')";
}
else {
return "WAValidateRQ("+"document." + document.theForm.formElement.options[document.theForm.formElement.selectedIndex].text+",'"+errorMsg+"',"+theFocus+","+stopIt+","+trimWhite+",'"+tagType+"')";
}
}
The line of code added was:
var tagType = theElementType;
in order to avoid the tagType not defined.
let me know if this is the correct solution to the problem.?