Display only the error messages from ASP validators using JavaScript

How can I display only error messages for validation controls, not the text itself? The code I have tried is displaying null for error messages.


function fnOnUpdateValidators() {
    for (var i = 0; i < Page_Validators.length; i++) {
        var val = Page_Validators[i];
        var ctrl = document.getElementById(val.controltovalidate);
        if (ctrl != null && ctrl.style != null) {
            if (!val.isvalid) {
                ctrl.style.background = '#FFD6AD';
                var errMsg = document.getElementById(val.id).getAttribute('ErrorMessage');
                alert(errMsg);
            } else {
                ctrl.style.backgroundColor = '';
             }
         }
     }
}

Answer №1

If you encounter an error message, simply use val.errormessage in your code instead of using getAttribute.

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

Tips for comparing JSON object structures: contrasting an array of objects like [{},{},{}] with a single object like {k:v, k2:v2

I have a PHP application where I receive two different JSON responses from two different tools. However, I want to utilize the same JavaScript code to handle both responses. My goal is to compare the following data structures: data = [ {'k1': ...

What is the process for obtaining authorization to access user information?

I am facing a perplexing issue with my app settings. Despite setting everything up correctly, I am unable to authenticate my account on my website using the Javascript SDK. Whenever I try to console.log(me), I only receive public information. Upon furthe ...

Updating style of element in EJS following POST request in Node.js using Express

I am working on a form page that is supposed to display a Success Alert (Boostrap) once the user fills out the form and clicks the Submit button. <form class="well form-horizontal" action="/contact" method="post" id="contact_form"> ... (input fiel ...

Navigate to a fresh HTML page upon form submission

I'm completely new to the world of web apps and JavaScript, and I'm facing an issue where my form submission doesn't redirect me to a thank you page. Instead, it just leads to a blank page every time. I've tried researching solutions on ...

How can I customize the font size of a label within a React Material UI Stepper?

Is it possible to modify the font size of stepper labels in React Material UI? If so, how can I accomplish this? function getSteps() { return [ "OPTION 1", "OPTION 2", "OPTION 3" "OPTION 4& ...

What is the process for integrating Internet Explorer 10 compatibility into a basic VueJs component?

I am facing an issue with a VueJs component that is not rendering in IE 10. Context: The Vue component I am working on is a company events list with basic filtering and sorting functionalities. Unfortunately, IE10 support is required for this project. Eve ...

Avoid using single quotes in Postgres queries for a more secure Node.js application

Snippet from my node js code: var qry = 'INSERT INTO "sma"."RMD"("UserId","Favourite") VALUES (' + req.body.user + ',' + JSON.stringify(req.body.favourite) + ')' My problem is inserting single quotes before JSON.stringify(r ...

Performing both insert and update operations with just a single click of a button is possible in c

I have been working on a method called uniqueEmail() to insert and update data using the same button. The goal is to verify if the email address already exists in the table before performing any operations. However, I seem to be encountering some issues ...

What steps should I follow to integrate Semantic UI into a project using React and Express?

As a newcomer to Semantic/React/Express, I am wondering how to incorporate the stylesheet for Semantic in React. Do I need an html file that directly references the Semantic css and JavaScript files? Currently, I am not utilizing any html files. In my mai ...

Keeping the scroll in place on a Bootstrap4 modal while scrolling through content that is already at the top

On my Bootstrap 4 modal, I have encountered an issue with scrollable content. When I am at the top of the content and try to scroll downwards, nothing happens because I am already at the top. However, if I continue to hold the touch without releasing it, t ...

JSON Date Format

I'm facing an issue where I am unable to retrieve the current date using new Date() because it is in JSON format. This particular code was written using MVC C#. The date appears as \/Date(1531364413000)\/. The dates stored in the database ...

Utilizing HTML and JavaScript to dynamically switch stylesheets based on the width of

When it comes to using stylesheets for mobile and non-mobile devices, there is a need for different approaches. The idea of comparing browser height and width in JavaScript seems like a good one, but the implementation may not always work as expected. ...

What are the steps for accessing a server-side WebControl from the client side?

Issue Overview: I am facing a problem with managing different types of input values in my dialog box. Depending on the selection from a dropdown list, the required input could be simple text, a date, or specific data from a database. I have successfully i ...

Embracing the Legacy of jQuery's Event Handling Mechanism

I am in the process of developing an SDK for a website's API that relies on jQuery. I am interested in incorporating jQuery's custom events model into the SDK. How can I effectively integrate, encapsulate, or otherwise leverage jQuery's even ...

Execute a WebGL script within a three.js application

Is there a way to incorporate the webgl function gl.blendFunc(gl.ONE, gl.ONE) into my three.js script effectively? Your help would be greatly appreciated. ...

Include the URL as a parameter in the query when utilizing Tesseract OCR

I have successfully implemented the tesseract ocr, but I am wondering if it is possible to run tesseract with a URL as a parameter. I want to achieve the following: localhost/test.html/?othersite.com/image/image2.jpg Here are some image URLs for demonst ...

Display pie charts on a Google Map

Utilizing a combination of JavaScript and GoogleMaps technology Within my application, there exists a screen showcasing a Google Map. In addition to this map, I have incorporated statistics detailing Population growth data displayed in the form of Pie Cha ...

What should I do to resolve the issue of the function if ($(window).width() < 768) {} not functioning properly upon resizing the browser?

I am working on a functionality where the navigation bar items will toggle hidden or shown only when the browser width is less than 768px and an element with the class "navlogo" is clicked. I have included my code below for reference. if ($(window).width( ...

Prevent IonContent from scrolling to the bottom or top when using Ionic framework

In my Ionic app, I have a long text page with 2 buttons that trigger the actions scrollToBottom and scrollToTop. Due to the length of the page, I have set the scroll duration to be 30 seconds. I am facing two issues here: How can I stop the scrolling ...

How can one efficiently copy portions of object arrays in JavaScript while maintaining elegance?

I have two sets of data. Set arrayOne consists of elements of type myObject1: var myObject1 = { Id: 1, //key params: { weight: 52, price: 100 }, name: "", role: "" }; Set arrayTwo consists of elements of type myObject2: var myObject2 = { I ...