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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:30:55+00:00 2026-05-15T12:30:55+00:00

In a form a text box is created dynamically by clicking on add button

  • 0

In a form a text box is created dynamically by clicking on add button such that the text box is created in a new row.Now my problem is the validation of text boxes which were created dynamically such that it shows a message if any of text boxes are left empty when form is submitted by clicking submit button.Please help me out.

EDIT

  <html>
   <head>

  <SCRIPT language="javascript">
   function addRow(tableID) {

    var table = document.getElementById(tableID);

    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);

    var cell1 = row.insertCell(0);
    var element1 = document.createElement("input");
    element1.type = "text";
    cell1.appendChild(element1);
 }

   </SCRIPT>
   </head>


   <body>


    <form onSubmit="return validateFormOnSubmit(this)">
   <INPUT type="button" value="Add More Symptom " onClick="addRow('dataTable')" />


    <TABLE id="dataTable" >
      <TR>

        <TD > 
          <INPUT type="text" name="symp[]" /> 
         </TD>
       </TR>
    </TABLE>
   <input type="submit" value="Submit" name="ADD_SUBMIT">
   </form>


  </body>    
  </html>

Above is the script to add new textboxes in a new row.
Now i require that when submit button is clicked, each text boxes should be validated whether it is empty or not on client side. The entered values in the text box should not disappear and number of empty text boxes should be same.

  • 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-15T12:30:56+00:00Added an answer on May 15, 2026 at 12:30 pm

    on the submit event of the form you simply need to collect all input text boxes that you find in the form and pass them into a validation function.

    Put this code in the <head> section of your page

    //This function here is only a cross-browser events stopper
    stopEvent = function(ffevent)
    {
       var current_window = window;
    
       if(current_window.event) //window.event is IE, ffevent is FF
       {
          //IE
          current_window.event.cancelBubble = true; //this stops event propagation
          current_window.event.returnValue = false; //this prevents default (usually is what we want)
       }
       else
       {
          //Firefox
          ffevent.stopPropagation();
          ffevent.preventDefault();
       };
    }
    
    function validateAllInputBoxes(ffevent)
    {
       var inputs = document.getElementsByTagName('input');
       for(var i = 0; i < inputs.length; ++i)
          if(inputs[i].type === 'text')
             //@Satish, maybe below you wrote by mistake if(inputs[i].value = '') thus all input elements values get cleared out.
             if(inputs[i].value === '') 
             {
                alert("form could not be sent one input text field is empty");
                stopEvent(ffevent);
             }
    }
    

    and in the the <form> tag place the following code:

    onsubmit="validateAllInputBoxes(event);"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a form application with 1 button and 1 text box to see
me created a zend form and want to add dynamic text box in it.
I have created one form.In that form,it put one textbox.That text box should take
I have a textbox in a form that I created. I want to add
Is there any html form class(text box) that does not allow null values. The
Setup: A form with a text box, a button, and a list box. The
I have a button that will create a new entry (row in a table)
I had been created text box custom validation control and I'm using this in
I have created one html form with following fields: Name (Text Box) Email (Text
In my windows form I have a text box and a button, the text

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.