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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:36:24+00:00 2026-06-14T07:36:24+00:00

I have simple form with 2 textfield Name and Phone and can add new

  • 0

I have simple form with 2 textfield Name and Phone and can add new field when click Add new button. You can refer here jsfiddle .

My problem is how to add new textfield without press Add New button? When user fill up Text Input name and Text Input Phone new row <tr class="person"> will automatically added.

My second problem is I’m not sure how to write code for delete.

UPDATE : I also want to set maximum clone, can this 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-06-14T07:36:25+00:00Added an answer on June 14, 2026 at 7:36 am

    If by “fill up” you mean “when the user enters as many characters as the Phone field allows” then you can add a maxlength="10" attribute to the input (setting the value as appropriate):

    <input type="text" name="phone[]" id="phone" maxlength="10"/>
    

    …and add a handler to the keyup event that checks whether the current value has reached the maxlength:

    $('input[name="phone\[\]"]').keyup(function() {
        if (this===$('input[name="phone\[\]"]').last()[0]
            && this.value.length===+$(this).attr("maxlength")) {
            $("#add").click();
        }
    });
    

    Note that you probably only want to do this test if the user is typing in the last row, hence the first part of the if test above.

    Also you probably want the newly cloned fields to be blank, so you can do this within your add function:

    $('#mytable tbody>tr:last').clone(true).insertAfter('#mytable tbody>tr:last')
                               .find("input").val("");
    

    To set a maximum number of rows you can put a test in your add function:

    $("#add").click(function() {
        var $lastRow = $('#mytable tbody>tr:last');
        if ($lastRow.index() < 10) { // set maximum rows here
            $lastRow.clone(true).insertAfter($lastRow).find("input").val("");
        }
        return false;
    });
    

    Note also that you don’t need to give those inputs an id attribute, but if you do you shouldn’t copy it when you clone because id should be unique.

    For a delete function, add a delete button to each row:

    <td><input type="button" class="deleteRow" value="Delete"/></td>
    

    …and then:

    $("#mytable").on("click","input.deleteRow", function(){
        if ($("#mytable tr").length > 2) // don't delete the last row
            $(this).closest("tr").remove();
    });
    

    Demo: http://jsfiddle.net/3J65U/15/

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

Sidebar

Related Questions

I have a very simple Project form with a name field and a select
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
Have a simple form (only extract fields here) but for some reason the JQserilization
I have a simple form like this : <form method=post name=change_pass id=change_pass action=change_pass2.php> <input
I'm new to rails and mongodb, and have a simple form attempting to create
I have got a simple HTMl form with one field as follows: <input type=text
I have a simple login form that has 2 text fields and a button.
I have a very simple voting form. It contains a single text field for
I have one simple User Registration form. It includes name, age, sex & city.
I'm new at django and I'm having problems with a simple form POST.I have

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.