Results 1 to 2 of 2

Thread: javascript: checking different parameters of form validation

  1. #1
    Join Date
    Sep 2010
    Posts
    10

    javascript: checking different parameters of form validation

    I've created a form.
    **********************************************************************
    <form id="form1" method="post">
    <table border="0">
    <tr>
    <td>User Id</td>
    <td><input type="text"name="User Id" id="UserId" /></td>
    </tr>

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

    <tr>
    <td>E-mail Address:</td>
    <td><input type="text"name="E-mail Address:" id="Email"/></td>
    </tr>

    <tr>
    <td>Name:</td>
    <td><input type="text"name="NameOfUser" id="NameNameOfUser"/></td>
    </tr>

    <tr>
    <td><input type="image" src="SUBMIT.gif" id="SubmitButton"/></td>
    <td><input type="image" src="RESET.gif" id="ResetButton"/></td>
    </tr>
    </table>
    </form>
    *******************************************************************
    Now I want to write javascript code for the processes inside the HTML file:
    1. check for the condition if any of the cell is NULL, if any one of the cell is NULL give an alert message.
    2. validation of e-mail address, like it must contain atleast one '@' 'dotcom(.com)'
    3. check the length of the name input


    I am learning javascript and not getting idea how to perform this task. Will anyone help me???

  2. #2
    Join Date
    Apr 2011
    Posts
    36
    Hy,
    With the following function you can check those conditions
    Code:
    function SubmitForm(id) {
    var objid = document.getElementById(id).value;
    if( (objid==NULL || objid.length<3 || objid.indexOf("@")==-1 || objid.indexOf('.')==-1) {
    
     alert("please complete email address corectly");
     return false;
    }
     else return true;
    }
    If you are learning JavaScript, study the code and adapt it for youre use.
    You need to create more if() conditions in that function, one separately for mail field.

Similar Threads

  1. JavaScript Form Validation
    By 809AreaCode in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 18 May 2011, 10:47 AM
  2. simple javascript validation for a signup form?
    By c_martini in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 25 Mar 2010, 03:07 PM
  3. Form input from URL parameters
    By Sargon in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 07 May 2008, 04:22 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
  •