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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:02:38+00:00 2026-06-17T21:02:38+00:00

In below code, there is a form to create login for new user. And

  • 0

In below code, there is a form to create login for new user. And on the press of continue button it should call ‘validateForm()’ function. Where it is checking the values filled in form and on missing of proper value(s) it should give the alert message. But, is not giving any alert even on error, like I am pressing ‘continue’ even the form is completely empty.

<html>
<head>
<title></title>
<script type="text/javascript">
function validateForm()
{
    var email=document.forms["newlogin"]["email"].value;
    var cemail=document.forms["newlogin"]["cemail"].value;
    var pass=document.forms["newlogin"]["pwd"].value;
    var cpass=document.forms["newlogin"]["cpwd"].value;
    var answ1=document.forms["newlogin"]["ans1"].value;
    var answ2=document.forms["newlogin"]["ans2].value;

    alert("I am IN");

    if(email==null || email=="" || cemail==null || cemail=="") {
        alert("Enter Email ID and confirm.");
        return false;
    }
    if(pass==null || pass=="" || cpass==null || cemail=="") {
        alert("Enter Password and confirm.");
        return false;
    }
    if(answ1==null || answ1=="" || answ2=null || answ2=="") {
        alert("Enter Answer 1 & Answer 2.");
        return false;
    }
    if(email!=cemail) {
        alert("Confirmed Email ID is not matching.");
        return false;
    }
    if(pass!=cpass) {
        alert("Confirmed Password is not matching.");
        return false;
    }
}
</script>
</head>


<body>
<h1 style="font:swis721 bt">enginenc</h1>
<form name="newlogin" method="POST" action="http://localhost/cgi-bin/createlogin" onsubmit="return validateForm()">
    <table align="center" cellpadding="10" cellspacing="0" style="margin-top:2cm;background-color:#FFD700;border-top:1px solid;border-bottom:1px solid;border-left:1px dotted;border-right:1px dotted" border=0>
        <tr>
            <td align="left" style="font:westwood let">Enter a valid Email ID:</td>
            <td align="left" style="font:westwood let"><input type="text" name="email"></td>
        </tr>
        <tr>
            <td align="left" style="font:westwood let">Confirm the Email ID:</td>
            <td align="left" style="font:westwood let"><input type="text" name="cemail"></td>
        </tr>
        <tr>
            <td align="left" style="font:westwood let">Enter password:</td>
            <td align="left" style="font:westwood let"><input type="password" name="pwd"></td>
        </tr>
        <tr>
            <td align="left" style="font:westwood let">Confirm Passowrd:</td>
            <td align="left" style="font:westwood let"><input type="password" name="cpwd"></td>
        </tr>
        <tr>
            <td align="left" style="font:westwood let">Select Question 1:</td>
            <td align="left" style="font:westwood let"><select name="ques1"><option value=1>1. What is your mother's maiden name?</option><option value=2>2. Which is your birth city?</option><option value=3>3. Which is your favorite place?</option></select></td>
        </tr>
        <tr>
            <td align="left" style="font:westwood let">Answer 1:</td>
            <td align="left" style="font:westwood let"><input type="text" name="ans1"></td>
        </tr>
        <tr>
            <td align="left" style="font:westwood let">Select Question 2:</td>
                        <td align="left" style="font:westwood let"><select name="ques2"><option value=1>1. Which is your dream car?</option><option value=2>2. What is your nick name?</option><option value=3>3. Who is your favorite singer?</option></select></td>
        </tr>
        <tr>
                        <td align="left" style="font:westwood let">Answer 2:</td>
                        <td align="left" style="font:westwood let"><input type="text" name="ans2"></td>
                </tr>
        <tr>
            <td align="left" style="font:westwood let"><input style="margin-left:3cm;padding:11px" type="submit" value="Continue"></td>
            <td align="left" style="font:westwood let"><input style="padding:11px" type="reset"></td>
        </tr>
    </table>
</form>
</body>
</html>

Here, on submit of the form using onsubmit()=”return validateForm()” function. Form is not calling the function validateForm(). I tried alot but did not find the error. Please help.
Thanks.

  • 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-17T21:02:39+00:00Added an answer on June 17, 2026 at 9:02 pm

    change

    var answ2=document.forms["newlogin"]["ans2].value;
    

    to

    var answ2=document.forms["newlogin"]["ans2"].value; //missing quote
    

    And

    if(answ1==null || answ1=="" || answ2=null || answ2=="") {
    

    to

    if(answ1==null || answ1=="" || answ2==null || answ2=="") {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the below code, there ia a form in the location /home/form.php .How can
I am trying to create a login form on my ASP.NET website. Currently, there's
Is there any better way to implement the below code <form id=myform onsubmit=return saveUserData('firstname','lastname');
I grabbed this code form JCarousel and just trying to understand these lines below.
I'm learning Java on my own; and therefore the code below has no function
The below code works when there are a few element in the To list
In the Code Below there are Two Classes. One Object of type two is
I have below code to insert a style into DOM (there is a use
Normally I use the below code, but is there a better way? lastOfMonth =
In the below code instead of specifying the tab name.. Is there anyway we

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.