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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:49:53+00:00 2026-06-17T12:49:53+00:00

I am validating my form using javascript validation as whole validation is working fine

  • 0

I am validating my form using javascript validation as whole validation is working fine but email validation is not working. My form code is as follows

<form method="post" action="contact.php" name="myForm" onsubmit="return validateForm()">

<h3>To know more contact us today.</h3>

    <table>
        <tr>
            <td>Name:
                <br />
                <input id="name" name="name" type="text" />
            </td>
        </tr>
        <tr>
            <td>Contact No:
                <br />
                <input id="contact" name="contact" type="text" />
            </td>
        </tr>
        <tr>
            <td>Email:
                <br />
                <input id="email" type="text" name="email" />
            </td>
        </tr>
        <tr>
            <td>Address:
                <br />
                <textarea cols="34" id="address" name="address" type="text"></textarea>
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" value="Submit" />
            </td>
        </tr>
    </table>
</form>

and my javascript code is as follows

  <script type="text/javascript">
        function validateEmail() {

            var emailID = document.["myForm"]["email"].value;
            atpos = emailID.indexOf("@");
            dotpos = emailID.lastIndexOf(".");
            if (atpos < 1 || (dotpos - atpos < 2)) {
                alert("Please enter correct email ID")
                document.myForm.email.focus();
                return false;
            }
            return (true);
        }
        function validateForm() {
            var x = document.forms["myForm"]["name"].value;
            if (x == null || x == "") {
                alert("First name must be filled");
                return false;
            }
            var x = document.forms["myForm"]["contact"].value;
            if (x == null || x == "" || isNaN(document.myForm.contact.value) || document.myForm.contact.value.length != 10) {
                alert("Contact Number Must be 10 Digits");
                return false;
            }
            var x = document.forms["myForm"]["email"].value;
            if (x == null || x == "") {
                alert("Email is must");
                return false;
            }
            else {

                var ret = validateEmail();
                if (ret == false) {
                    return false;
                }
            }
            var x = document.forms["myForm"]["address"].value;
            if (x == null || x == "") {
                alert("Address cannot be empty");
                return false;
            }
            return (true);
        }

    </script>
  • 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-17T12:49:55+00:00Added an answer on June 17, 2026 at 12:49 pm
    var emailID = document.["myForm"]["email"].value;
                          ^^
    

    Syntax error. Dot-notation or Square-bracket-notation. Pick only one (per property).

    I’m surprised that Firebug / Chrome Developer Tools / Dragonfly / etc didn’t give you a clear pointer to that when you were testing.

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

Sidebar

Related Questions

I have made a form validation using ajax post method. But i got the
In my LAMP application I am using Javascript for form validation but of course
I'm working on a simple JavaScript validation function for a html form, but have
Currently i am validating the validation form for phone number using the following code
I am done with validation using javascript for a form in PHP. When is
I'm try to validate form using jquery validation plugin my from code: source code
i am using a jquery validation in form my code is following Jquery $(document).ready(function
I am have completed javascript validation of a form using Regular Expressions and am
I am using a regular expression validation to validate my form using javascript. my
I'm submitting a form using the AJAX JQuery validation plugin. The code looks something

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.