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

  • Home
  • SEARCH
  • 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 7168503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:47:37+00:00 2026-05-28T14:47:37+00:00

I have controls that are dynamically added via javascript. I cannot set the class

  • 0

I have controls that are dynamically added via javascript. I cannot set the class on these controls to “required” because I need the flexibility to place the error messages where I will.
When I add these controls, I loop through all that I need required, and call

$("#dynamicControlID").rules("add", {required:true});

The problem comes when I try to validate the form. When I call

$("#form1").validate()

any non-dynamic controls that have the class “required” specified will validate with a nice message that says “this field is required.” The controls that have been added dynamically do not show any message, and the validate function returns true even if they’re empty.
The real confusion comes when I validate the dynamic controls individually. If I call

$("#dynamicControlID").valid()

it will return false, and display the error message by the input. I do call

$("#form1").valid()

before I do anything with the dynamic controls.

Am I missing something here? What I would like is to call

$("#form1").valid() 

and have the error messages show for all my dynamically added controls.

  • 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-28T14:47:38+00:00Added an answer on May 28, 2026 at 2:47 pm

    You’re on the right track, but when you want to add rules to the new element, you have to have already called $('#form1').validate();.

    So a common setup is something like this:

    $('#form1').validate({
       //your options
    });
    
    $('#dynamicControlID').rules('add',{required:true});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with user controls getting dynamically added. Inside some of these
I have a page that has 3 used controls that are dynamically added to
I have several different user controls that get built dynamically and added to a
I have a UserControl ('AddressInfoGroup') within an updatepanel that dynamically loads user controls ('AddressInfo')
I have a grid and I need to dynamically replace a control that resides
I have a list of controls that I am displaying via a WrapPanel and
Have a page that adds controls dynamically. Control state is being retrieved from database
I have a form where controls are dynamically added to a Panel. However, when
I am working on a winforms app and I have added some controls dynamically
I have following class that defines attached property to set children's margin: public class

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.