-1

I am trying to build a form which counts the total numbers of characters typed in it.My form contains fields like name,address and basic information about client.I want to get the total characters typed in all those fields.hw I should I do it.?`

HTML CODES

//

<form name="form_3" id="form_3" method="post" action="action_form_2.php">
    <table border="1" width="1300" height="200" bordercolour="BLUE" >

            <tr>
            <td>Name and Address of Company:: <textarea name="name_address1" cols="30" rows="6" ></textarea><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Years In job::<input type="text" name="years_job">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;Postion/Type of Business::&nbsp;&nbsp;<input type="text" name="pos_type">&nbsp;&nbsp;Years Employed in this profession::<input type="text" name="years_employed" id="years_emp">
                Business Phone::<input type="text" name="phone_no" id="phone_no" >
                <input type="checkbox" name="self_employed" id="self_employed" value="self">Self Employed<br>
            </td>

           <td>Name and Address of Company:: <textarea name="name_address2" cols="30" rows="6" ></textarea><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Years In job::<input type="text" name="years">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
               &nbsp; Postion/Type of Business::&nbsp;&nbsp;<input type="text" name="type" >&nbsp;&nbsp;Years Employed in this profession::<input type="text" name="years_emp">
                 Business Phone::<input type="text" name="phone" id="phone"   >
                <input type="checkbox" name="self_employed" id="self_employed" value="self">Self Employed<br>
            </td>

            </tr>

             </table>
              <h4>iv.EMPLOYMENT INFORMATION</h4> 
           <table border="1" width="1300" height="200">
            <tr>
            <td>Name and Address of Company:: <textarea name="name_address3" cols="30" rows="6" ></textarea><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Years In job::<input type="text" name="years" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position/Type of job::<input type="text" name="positions" ><br>
                &nbsp;&nbsp;&nbsp;Date(frm-to)::&nbsp;&nbsp;<input type="text" name="date" >&nbsp;&nbsp;Monthly Income::<input type="text" name="date" >
                  Business Phone,inc area code::<input type="text" name="phone" >
                <input type="checkbox" name="self_employed" id="self_employed" value="self"  >Self Employed<br>
            </td>
            <td>Name and Address of Company:: <textarea name="name_address4" cols="30" rows="6" ></textarea><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Years In job::<input type="text" name="years">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position/Type of job::<input type="text" name="positions"><br>
                &nbsp;&nbsp;&nbsp;Date(frm-to)::&nbsp;&nbsp;<input type="text" name="date">&nbsp;&nbsp;Monthly Income::<input type="text" name="date">
                  Business Phone,inc area code::<input type="text" name="phone" >
                <input type="checkbox" name="self_employed" id="self_employed" value="self">Self Employed<br>
            </td>

            </tr>

            <tr>
              <td>Name and Address of Company:: <textarea name="name_address5" cols="30" rows="6" ></textarea><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Years In job::<input type="text" name="years">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position/Type of job::<input type="text" name="positions"><br>
                &nbsp;&nbsp;&nbsp;Date(frm-to)::&nbsp;&nbsp;<input type="text" name="date">&nbsp;&nbsp;Monthly Income::<input type="text" name="date">
                  Business Phone,inc area code::<input type="text" name="phone">
                <input type="checkbox" name="self_employed" id="self_employed" value="self">Self Employed<br>
            </td>
             <td>Name and Address of Company:: <textarea name="name_address" cols="30" rows="6" ></textarea><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                Years In job::<input type="text" name="years">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Position/Type of job::<input type="text" name="positions"><br>
                &nbsp;&nbsp;&nbsp;Date(frm-to)::&nbsp;&nbsp;<input type="text" name="date">&nbsp;&nbsp;Monthly Income::<input type="text" name="date">
                  Business Phone,inc area code::<input type="text" name="phone">
                <input type="checkbox" name="self_employed" id="self_employed" value="self">Self Employed<br>
            </td>

            </tr>

             </table>  
        <h4>MONTHLY INCOME AND COMBINED HOUSING EXPENSE INFORMATION</h4>


            <table border="1"  width="1300" height="150">
              <tr>
                <td>Gross monthly income</td>
                <td>Borrower</td>
                <td>Co-borrower</td>
                <td>Total</td>
                <td>Combined Monthly Housing Exp.</td>
                <td>Present</td>
                <td>Proposed</td>
            </tr>
             <tr>
             <td>Base EMPL income<</td>
             <td>$::<input type="text" name="empl_income" id="empl_income"></td>
             <td>$::<input type="text" name="co_borrower" ></td>
             <td>$::<input type="text" name="base_empl_total"></td>
                <td>Rent</td>
                <td>$::<input type="text" name=""></td>
                 <td>$::<input type="text" name="years"></td>
             </tr>
               <tr>
             <td>Overtime</td>
             <td>$::<input type="text" name="overtime_borrower"></td>
             <td>$::<input type="text" name="overtime_coborrower"></td>
              <td>$::<input type="text" name="overtime_total"></td>
             <td>Mortgaged</td>
             <td>$::<input type="text" name="years"></td>
              <td>$::<input type="text" name="years"></td>
             </tr>
             </table>

       <br>
       <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        <input type="submit" name="submit" value="SUBMIT" onclick="return validateform();">


    </body>
</html>
4
  • Please don't mind posting your HTML and code which you tried.
    – Satpal
    Jun 16, 2014 at 9:47
  • @satpal.have no idea how to do it...
    – saji
    Jun 16, 2014 at 9:47
  • 1
    @saji, SO is not a places for Basics, try atleast something.them come here with your code Jun 16, 2014 at 9:49
  • @satpal..added my html to the question.?Actually I am looking to work on a bpo software were I want to get the total characters typed in certain time.
    – saji
    Jun 16, 2014 at 9:52

1 Answer 1

1

Just iterate through all the form fields that contain inputted text and count their lengths:

$('#yourform').on('submit', function(){
  var count = 0;
  $('input[type="text"], textarea', this).each(function(){
    count += $(this).val().length;
  });
  // your total is in count variable
  return false; // or true to submit form
});

I put this into a jsFiddle with your HTML: http://jsfiddle.net/MUs7s/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.