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 6803091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:18:08+00:00 2026-05-26T19:18:08+00:00

I have a dropdown list that I’m converting over to a custom modal dialog.

  • 0

I have a dropdown list that I’m converting over to a custom modal dialog. The conversion requires that we have a text field that shows the name of the item selected and a hidden field that holds the ID of the item selected:

<input id="template" type="text" class="text inactive" value="Select a template...">
<span class="button">Select...</span>

<input id="templateid" type="hidden" class="required" name="template" title="You must select a template.">

When the user clicks on the Select… button, a modal dialog pops up, allowing the user to pick a template. After the user is done selecting a template, the template text box is set with the name of the template, and the templateid hidden field is set with the ID of the template:

$('#templateDialog .okButton').click(function() {
    var item = $(this).find('li.selected');
    var name = item.find('.name').text();
    var id = item.find('.id').text();
    
    $('#template').val(name);
    $('#templateid').val(id);
    $('#templateDialog').dialog('close');
});

All this is working fine. The issue I’m running into now is validation, using jQuery Validation. Because the hidden input has the required class, when I try to submit the form without picking a template, the error message is displayed properly. However, the template text box is not styled. I would like it to get the invalid class.

My question is, how do I configure jQuery so that, if the templateid hidden field is invalid, the template text box is invalid as well, and if it’s valid, the text box is valid as well?

Update: here’s a picture:

See how the Confirm password text box has a red outline, but the Template text box does not? I’d like for it to be red too.

  • 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-26T19:18:09+00:00Added an answer on May 26, 2026 at 7:18 pm

    jQuery validation plugin provides two handlers to customize the way the erroneous fields are changed visually: highlight and unhighlight.

    $(".selector").validate({
        highlight: function(element, errorClass, validClass) {
    
            if ([case of the input]) {
            // check here the case of you file input and add the errorClass to the file input or its container
            }
            else {
             // don't forget to apply the class to element in the other cases as defining this handler will remove the default behavior
                $(element).removeClass(validClass).addClass(errorClass);
            }
         }
    });
    

    Do the contrary with unhighlight handler.

    Hope this helps,
    d.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to create a text field with a dropdown list that lets the
I have a dropdown list that stores name/value pairs. The dropdown appears in each
I have a dropdown list with a piece of code that is run when
I have a dropdown list that I want to show only certain options when
i have an asp.net-mvc webpage and i want to show a dropdown list that
I have a dropdown list that is currently populated from a result set of
I have a dropdown list that I am binding to a datatable. Here is
I'm using Jquery 1.6. I have a dropdown list that has a bunch of
I have a dropdown list box that displays data from my database. Problem is
I am running into a strange issue. I have a dropdown list that contains

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.