Displaying Meteor session variables in templates in a user-friendly and descriptive manner rather than as html code

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.

Answer №1

To properly escape HTML tags, make sure to use three curly braces

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieving device information through JavaScript, jQuery, or PHP

Looking to build a website that can identify the device name and model of visitors accessing the page from their devices. ...

Utilizing the power of Angular's $resource within a factory to showcase information stored in a deeply nested

Just starting to explore the world of $resource concepts and facing a challenge with a piece of code that involves fetching data from a nested JSON. I've created a factory method that successfully retrieves the data and I can see it in the response he ...

Tips for modifying a HTML table to switch one column with 60 rows to three columns with 20 rows dynamically

Need assistance with separating a dynamically loaded single-column HTML table of 60 rows into three columns of 20 rows each using jQuery in JSP. For example, starting with the loaded table: test 1 test 2 test 3 test 4 test 5 test 6 test 7 test 8 test 9 t ...

Ionic 2's Navigation Feature Failing to Function

I need to implement a "forgot password" feature on my login page. When a user clicks the button, they should be redirected to the "forgot password" page. Below is the code snippet from my login.html <button ion-button block color="blue" (cli ...

Placing a hyperlink within template strings

Currently, I am working on implementing a stylish email template for when a user registers with their email. To achieve this, I am utilizing Express and Node Mailer. Initially, my code appeared as follows: "Hello, " + user.username + ",&bs ...

What could be causing the data in getServerSideProps to be altered?

After fetching data from an API and passing it to index.js using getServerSideProps, I noticed that the prop array is initially in order by rank [1, 2, 3, etc]. Here's an example of the data: [ {rank: 1, price: 123}, {rank: 2, price: 1958}, {rank: ...

How can the radio button's checked property be bound to a boolean attribute of a component in Angular 2?

Is there a way to connect the checked property of a radio button to a boolean variable in a Component class? I would like the radio button in the template to be pre-selected if the boolean flag is true. I attempted to use <input type="radio" [(ngModel) ...

Are you ready to put Jest to the test by checking the completion event of

The RxJS library's Observer triggers three main events: complete error next If we want to verify the occurrence of the complete event using Jest, how can this be achieved? For instance, we are able to test the next and error events by checking for ...

Having trouble with ui-sref functionality within a Bootstrap dropdown menu

In the header.html file, I have the following angular code: <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> &l ...

Updating the Ajax Url dynamically while scrolling

I am trying to update the Ajax URL dynamically, and here is my progress so far: var size=1; var from = 1; window.addEventListener('mousewheel', function(e){ if(e.wheelDelta<0 && from<5){ from++; } else if(e.whe ...

Issue with Tweening in Three.js: Initial value does not change

Having trouble with tweening my camera position. I've set up a Codepen with minimal code to showcase the issue, complete with annotations and plenty of console.log() statements for debugging purposes. Check out the Codepen The starting point of my c ...

Capturing screenshots with Selenium in Node.js is proving to be quite sluggish

My current project involves using Selenium with Mocha in Node.js for UI testing on a website. I want to capture screenshots after each test to review and share the results visually. The challenge arises when there are AJAX calls and JavaScript animations ...

Trouble parsing JSON in Classic ASP

After receiving a JSON Response from a remote server, everything looks good. I discovered an helpful script for parsing the JSON data and extracting the necessary values. When attempting to pass the variable into JSON.parse(), I encountered an error which ...

Utilize the return value within a .map function following the completion of a request.get call

Essentially, for security reasons, I need to convert an image from a URL to base64. Currently, I have two functions in place. One function is responsible for converting the image from the URL to base64, and the other function is iterating over the databas ...

Error in Typescript for a function that accepts several types of lists - property does not exist on the interface

In my project, I have defined three interfaces: a base interface and two others that extend the base one with children as properties. One of the interfaces includes 'valueType' while the other includes 'returnType'. Here is how they are ...

Initializing data in VueJS for objects that do not already exist

I'm currently using Ajax to populate data properties for multiple objects, but the properties I want to bind to don't exist at the time of binding. For example: <template> <my-list v-bind:dataid="myobject ? myobject.data_id : 0">& ...

Discovering the file extension and ensuring its validity when imported from Google Drive

I am facing an issue with a select tag that has 3 options: powerpoint, pdf, and spreadsheet. When uploading from Google Drive, there is no validation in place, so I can give a ppt link to the pdf option and it will still upload. Can someone help me with va ...

The combination of PHP and JavaScript looping is struggling to produce the correct sequence of results

for(var i=0; i<participantNum; i++){ studentID = $('#txtID'+(i+1)).val(); alert(studentID); //implementing a PHP function to validate each student's ID by making AJAX calls request("http://localhost/lastOrientation/2_regis ...

Encountering the error "Cannot access property 'stroke' of undefined" when utilizing constructors in React and p5

Hi there, I'm having trouble with my React code and could really use some assistance. Being new to React, I'm trying to create a collision system between multiple bubbles in an array, but I keep running into this undefined error: https://i.sstat ...

Get the Google review widget for your web application and easily write reviews using the Google Place API

I developed a platform where my clients can provide feedback and ratings on my services through various social media platforms. Currently, my main focus is on collecting Google reviews using a Google widget/flow. https://i.sstatic.net/RvPst.png The imag ...