Currently, I am in the process of loosely validating a group of fields within a multistage form to ensure that essential data is present before moving forward. The validation function I have created is quite basic at the moment, as my main goal is to establish functionality before delving into more detailed data validation.
function validateCustTab(){
Session.set("custTabErrorMsg", "");
Session.set("custTabError", false);
if($('input:text[name=customerSearch]').val() === "")
{
Session.set("custTabErrorMsg", Session.get("custTabErrorMsg") + "<div class='row'>* Require a Customer To Proceed </div>");
Session.set("custTabError", true);
}
if($('input:text[name=orderLoadNum]').val() === ""){
Session.set("custTabErrorMsg", Session.get("custTabErrorMsg") +"<div class='row'>* Require a Unique Load Number To Proceed </div>");
Session.set("custTabError", true);
}
if($('input:text[name=orderPlacedDate]').val() === ""){
Session.set("custTabErrorMsg", Session.get("custTabErrorMsg") +"<div class='row'>* Require an Order Entry Date To Proceed </div>");
Session.set("custTabError", true);
}
if($('input:text[name=orderCharges]').val() === ""){
Session.set("custTabErrorMsg", Session.get("custTabErrorMsg") +"<div class='row'>* Require Order Charges To Proceed </div>");
Session.set("custTabError", true);
}
if(Session.get("custTabError")){
Modal.show('orderEntryCustTabErrorModal');
console.log("Not Valid");
return false;
}else{
console.log("Valid");
return true;
}
}
The parent function responsible for calling this validator checks for a true or false value and then proceeds to display the next stage or showcases a modal with error messages. Everything seems to be functioning correctly, except that the information displayed in the modal appears as an exact duplicate of the string stored in the session variable. It seems that the HTML content is not being parsed accordingly. I have experimented with different strategies such as using
tags instead of div rows, as well as attempting to remove HTML and use \n for line breaks, but none of these approaches have been successful.
I have included a screenshot of what I am experiencing:
https://i.sstatic.net/oJbRF.jpg
My objective is to resolve how to display this multiline error message within the modal effectively. It seems that there might be a small detail that I am overlooking in this process.