Results 1 to 2 of 2

Thread: problem with form submission

  1. #1
    Join Date
    Sep 2010
    Posts
    10

    problem with form submission

    My form is:
    *****************************
    <form name="RegistrationForm" id="form1" method="post">
    <table border="0">
    <tr>
    <td>User_Id</td>
    <td><input type="text"name="User_Id" id="User_Id" /></td>
    </tr>

    <tr>
    <td>Date</td>
    <td><input type="text"name="Date" id="Date" /></td>
    </tr>

    <tr>
    <td><input type="image" src="submit.gif" onclick="SubmitForm()"/></td>

    ****************************************************************
    Now I want to check if both of the fields are entered before pressing the Submit button.
    Also if one of the field is not completed before submitting the form, it will generate an error message. and the user has to fill the left fields of the form.
    but it must restore the previous filled values.
    I've tha js code as:
    *******************************************
    function SubmitForm()
    {
    if( (document.getElementById('User_Id').value=="") || (document.getElementById('Date').value=="") )

    alert("please complete the form");
    return false;
    }

    else return true;
    }

    *********************************************
    But this code wont restore the previous values. I've to re-enter all the values. How can I write js code for this problem??

  2. #2
    Join Date
    Apr 2011
    Posts
    36
    Hy,
    Try with this code:
    Code:
    <form name="RegistrationForm" action="" id="form1" method="post" onsubmit="return SubmitForm();">
    <table border="0">
    <tr>
    <td>User_Id</td>
    <td><input type="text"name="User_Id" id="User_Id" /></td>
    </tr>
    <tr>
    <td>Date</td>
    <td><input type="text"name="Date" id="Date" /></td>
    </tr>
    <tr>
    <td><input type="image" src="submit.gif" /></td></table></form>
    
    <script type="text/javascript"><!--
    function SubmitForm()
    {
    if( (document.getElementById('User_Id').value=="") || (document.getElementById('Date').value=="") ) {
    
     alert("please complete the form");
     return false;
    }
     else return true;
    }
    --></script>

Similar Threads

  1. Submission Form for newbie
    By yochoice in forum The Lounge
    Replies: 1
    Last Post: 01 Feb 2011, 01:32 AM
  2. Need someone to make me an Automatic Submission Form
    By hartattack_199 in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 14 Jul 2009, 06:59 AM
  3. Submission Form Webpage Needed
    By learning in forum Job Offers
    Replies: 0
    Last Post: 22 Mar 2009, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •