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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:52:31+00:00 2026-05-21T06:52:31+00:00

I have a web page that has a few text boxes, and a dual

  • 0

I have a web page that has a few text boxes, and a dual list control. All of these data elements are for a particular entity. The form is for creating a new instance of this entity and saving it to the database. The dual list shows available people to use, and the user can move options from the available list to the selected list. All of this works perfectly when posted. There is a button at the bottom of the page to post the form.

To make things easy, I also want to include a hidden “form” that lets the user add a new person to the dual list without leaving the page. They click an “Add New” link which shows a previously hidden div. In the div are two text boxes: “emailName” and “emailAddress”, and a button to click called “Add”.

When the user clicks the “Add” button I need to validate the emailName and emailAddress fields, and only those two fields. If they are valid then I will make my AJAX request and handle the return data by adding a new option to the dual list.

  • 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-21T06:52:32+00:00Added an answer on May 21, 2026 at 6:52 am

    Here’s the solution I am using.

    First, I disable validation of my partial’s form elements and never re-enable it. I do this by specifying a class selector in the validator options using a custom script that’s referenced in the main page.

    Then, on my parital’s button click I call validator.element for each element. If they are all valid then I perform the AJAX request.

    Calling .element will show the validation message for the field and return a boolean indicating if it’s valid. You have to check these carefully to avoid boolean operator short-circuiting issues, to make sure all the error messages get shown. I used the bitwise & to accomplish this.

    var validator = $("#EmailRecipient_Name").closest("form").validate();
    
    //validator.settings.defaultIgnoreClass is defined in a custom script, and set to ".ignoreValidation"
    $("#EmailRecipient_Name").addClass(validator.settings.defaultIgnoreClass);
    $("#EmailRecipient_Email").addClass(validator.settings.defaultIgnoreClass);
    
    $("#addNewRecipientLink").click(
        function () {
            $("#addNewRecipientBox").toggle()
    
            return false;
        }
    );
    
    $("#addNewRecipient").click(
        function(){
    
            var validator = $("#EmailRecipient_Name").closest("form").validate();
    
            if ( validator.element( "#EmailRecipient_Name" ) & validator.element( "#EmailRecipient_Email" ) )
            {
                $.post(
                    "@Url.Action( "Create", "EmailRecipient" )",
                    {
                        Name: $("#EmailRecipient_Name").val(),
                        Email : $("#EmailRecipient_Email").val()
                    },
                    function( data ){
                        if ( data.ErrorMessage )
                        {
                            alert( data.ErrorMessage );
                        }
                        else
                        {
                            $("#SelectedEmailRecipients").append("<option value='" + data.EmailRecipientID + "'>" + data.Name + "</option>");
                            $("#EmailRecipient_Name").val("");
                            $("#EmailRecipient_Email").val("");
                        }
                    }
                );
            }
    
            return false;
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application I have a user profile page. That page has these
In a web application, I have a page that contains a DIV that has
I have a search program that has multiple input text boxes that correspond to
I have a web page that includes a bunch of images. Sometimes the image
I have a web page that displays a long line graph inside a div
I have a web page that is being displaying in a winform app using
I have a web page that renders the same in IE7, Firefox, and Safari
Let's say I have a web page that currently accepts a single ID value
I have a simple web page that till now didn't need any login. It
I have an ASP.NET web page that displays a variety of fields that need

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.