Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6127829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:33:25+00:00 2026-05-23T16:33:25+00:00

using javascript validation and some jquery to show variable error messages in the DOM,

  • 0

using javascript validation and some jquery to show variable error messages in the DOM, and highlighting both the form label and field.

For this particular error message, I need to highlight 2 fields (email1 and email2).
Unsure how to add it to my current setup for alerts below:

customAlert ("email2",bnadd_msg_022);

simple question, how to I add email1 into the mix?

Edit:

Here is my jquery function:

function customAlert(inputID,msg){

      $("li").removeClass("alertRed");
      $("input").removeClass("CO_form_alert");  
      $("select").removeClass("CO_form_alert");   
      var div = $(".errorPopup");
      div.css({"display":"block"});
      $("#"+inputID).addClass("CO_form_alert").parent().addClass("alertRed");
      if (div.length == 0) {
        div = $("<div class='errorPopup' onclick='$(this).hide();'></div>");
        $("body").prepend(div);
      } 
      div.html(msg);
      $("#"+inputID).focus(function(){
        $(this).unbind('focus'); // remove this handler
        $('.errorPopup').hide(); // hide error popup
   });

So, In this case and on one other, I need to highlight 2 fields simultaneously

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:33:25+00:00Added an answer on May 23, 2026 at 4:33 pm

    I’d make use of the arguments ‘array’ in Javascript, and simply define customAlert as a function with no arguments.

    function customAlert(){
        var args = arguments;
        if(args.length > 1) {
            // check that custom alert was called with at least two arguments
            var msg = args[0];
            $("li").removeClass("alertRed");
            $("input").removeClass("CO_form_alert");  
            $("select").removeClass("CO_form_alert");   
            var div = $(".errorPopup");
            div.css({"display":"block"});
            if (div.length == 0) {
                div = $("<div class='errorPopup' onclick='$(this).hide();'></div>");
                $("body").prepend(div);
            } 
            div.html(msg);
            for(var i = 1; i < args.length; i++) {
                var inputID = args[i];
               $("#"+inputID).addClass("CO_form_alert").parent().addClass("alertRed");
                $("#"+inputID).focus(function(){
                    $(this).unbind('focus'); // remove this handler
                    $('.errorPopup').hide(); // hide error popup
                });
            }
         }
    }
    

    Then you call it like so:

    customAlert(bnadd_msg_022,"email2"); // note the order of the arguments has changed
    customAlert(bnadd_msg_022,"email1","email2");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My latest project is using a javascript framework (jQuery), along with some plugins (validation,
I am try to write some validation script using javascript and prototype. What I
I want to do some client side validation using javascript in ASP.NET page. I
I am done with validation using javascript for a form in PHP. When is
I am using the jQuery validation plugin on my form. I set the basic
I'm using jQuery ajax to give the user some visual validation feedback. I have
Using javascript or jquery, how can I make a Required Field Validator control (of
I have some client-side JavaScript validation on a form. It works great. But I
Ive got some form validation on my page thats ment to display an error
I'm using ASP.NET MVC Validation. I want to know in my javascript functions whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.