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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:03:00+00:00 2026-05-30T20:03:00+00:00

How to created textbox dynamically , when i click add button. after i put

  • 0

How to created textbox dynamically , when i click add button.

after i put the input field in the text box.

how to validate the dynamically created textbox using javascript or jquery.

<html>
<head>
<title>Adding and Removing Text Boxes Dynamically</title>

<script type="text/javascript">
var intTextBox=0;
//FUNCTION TO ADD TEXT BOX ELEMENT 
function addElement(){
  intTextBox = intTextBox + 1;
  var contentID = document.getElementById('content');
  var newTBDiv = document.createElement('div');
  newTBDiv.setAttribute('id','strText'+intTextBox);
  newTBDiv.innerHTML = "Text "+intTextBox+": <input type='text' id='" + intTextBox + "'    name='" + intTextBox + "'/>"; 
  contentID.appendChild(newTBDiv);
}

  </head>
  <body>
    <p>Demo of Adding and Removing Text Box Dynamically using JavaScript</p>
    <p><a href="javascript:addElement();" >Add</a> 
       <a href="javascript:removeElement();" >Remove</a>
    </p>
    <div id="content"></div>
    <input type="button" value="submit"/>
  </body>
  </html>

after when i click submit button all textbox validation must be done….

  • 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-30T20:03:02+00:00Added an answer on May 30, 2026 at 8:03 pm

    Try to copy this and test. And let’s tell me that is as you need.

    <!DOCTYPE HTML>
    <html>
    <head>
    <title>Adding and Removing Text Boxes Dynamically</title>
    
    <script type="text/javascript">
    var intTextBox = 0 ;//FUNCTION TO ADD TEXT BOX ELEMENT 
    function addElement(){
        intTextBox += 1
      var contentID = document.getElementById('content');
      var newTBDiv = document.createElement('div');
      newTBDiv.setAttribute('id','strText'+intTextBox);
      newTBDiv.innerHTML = "Text "+intTextBox%x+": <input type='text' id='%2+ intTextBox + "'    name='" + intTextBox + "' />"; 
      contentID.appendChild(newTBDiv);
    }
    
    function removeElement(){
        var element = document.getElementById("strText"+intTextBox);
        console.log(element);
        while (element.firstChild) {
            element.removeChild(element.firstChild);
        }
        intTextBox -=1;
    }
    </script>
    </head><body>
    <p>Demo of Adding and Removing Text Box Dynamically using JavaScript</p>
    <p><a href="javascript:addElement()" >Add</a> 
       <a href="javascript:removeElement();" >Remove</a>
    </p>
    <div id="content"></div>
    <input type="button" value="submit"/>
    </body>
    </html>
    

    See more at My jsFiddle

    Note : working with FireFox & Chrome

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

Sidebar

Related Questions

I dynamically created a table with three columns. <tr> <td>1</td> <td>SegName</td> <td><input type='text' /></td>
I created my own custom date picker consisting of an ASP TextBox, Button, and
I created a form with a label, textbox and a button. In the form
I'm trying to add the jVal attribute to a textbox that I created in
i have textbox controls that are created dynamically in the ASP.NET. I want to
I have a dynamically created (runtime creation) textbox whose name is available as a
When i create the text and label box dynamically it should sit in the
I intend to use Javascript to dynamically create a group of html elements (input
I would like to select a textbox being dynamically created by an asp.net server
I am trying to dynamically add items to a list adapter using an alert

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.