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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:09:56+00:00 2026-05-30T10:09:56+00:00

On client I create some inputs, for example: var title = document.createElement(‘input’); title.setAttribute(‘type’, ‘text’);

  • 0

On client I create some inputs, for example:

var title = document.createElement('input');
title.setAttribute('type', 'text');
title.setAttribute('name', 'Title');
myForm.appendChild(title);

This field should be required. How can I do this validation?

  • 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-30T10:09:57+00:00Added an answer on May 30, 2026 at 10:09 am

    How can I do this validation?

    You should apply HTML5 data-* attributes to it that are used by the jquery unobtrusive validation and then call jQuery.validator.unobtrusive.parse to force the plugin reparse the rules that have been dynamically added:

    var title = document.createElement('input');
    title.setAttribute('type', 'text');
    title.setAttribute('id', 'Title');
    title.setAttribute('name', 'Title');
    title.setAttribute('data-val', 'true');
    title.setAttribute('data-val-required', 'This field is required');
    myForm.appendChild(title);
    
    $(myForm).removeData("validator");
    $(myForm).removeData("unobtrusiveValidation");
    $.validator.unobtrusive.parse(myForm);
    

    Also notice that you might want to provide a corresponding <span> element that will be used to display the error message unless you are using the Html.ValidationSummary helper to centralize all error messages in a single location. This element should look like this:

    <span class="field-validation-valid" data-valmsg-for="Title" data-valmsg-replace="true"></span>
    

    which could be written in a more jQueryish way:

    $(function () {
        $.validator.unobtrusive.parse(
            $('form').append(
                $('<input/>', {
                    type: 'text',
                    id: 'Title',
                    name: 'Title'
                })
                .attr('data-val', 'true')
                .attr('data-val-required', 'This field is required')
            )
            .append(
                $('<span/>')
                    .addClass('field-validation-valid')
                    .attr('data-valmsg-for', 'Title')
                    .attr('data-valmsg-replace', 'true')
            )
            .removeData('validator')
            .removeData('unobtrusiveValidation')
        );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a form with some inputs and other information on a client by
I am trying to create a standalone client to consume some web services. I
Client side javascript code creates some elements (about 50-100) in a cycle: for (var
How can I create client proxy if I know only the type of service
i created an additional content type called clients where I can create new client
I have contemplating how to handle paper document input in Webapps for some time.
I have client/server data passing all working correctly. Text, Images, etc. My users create
Background I have been asked by a client to create a picture of the
I want to create a client side mail creator web page. I know the
I've been trying to create a client side editor which allows the end user

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.