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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:21:08+00:00 2026-05-23T17:21:08+00:00

I have a form that I want to validate looks like this: <!DOCTYPE html

  • 0

I have a form that I want to validate looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="scripts/validate.js"></script>
</head>
<body>
<form name="frmRegister" method="post" action="register.aspx"  onsubmit="return validate(this);">
    <div>
      <label for="txtUsername">Username:</label>
      <input type="text" name="txtUserName" id="txtUserName" size="12" />
    </div>
    <div>
      <label for="txtPassword">Password: </td></label>
      <input type="password" name="txtPassword" id="txtPassword" size="12" />
    </div>
    <div>
      <label for="txtPassword2">Confirm your password:</label>
      <input type="password" name="txtPassword2" id="txtPassword2" size="12" />
    </div>
    <div>
      <input type="submit" value="Log in"  />
    </div>
</form>
</body>
</html>

and the validate function in an external file called validate like this:

function validate(form) {
  var returnValue = true;
  var username = form.txtUserName.value;
  var password1 = form.txtPassword.value;
  var password2 = form.txtPassword2.value;

if(username.length < 6) {
  returnValue = false;
  alert("Your username must be at least\n6 characters long.\nPlease try again.");
  frmRegister.txtUserName.focus();
}

if (password1.length < 6) {
  returnValue = false;
  alert("Your password must be at least\n6 characters long.\nPlease try again.");
  frmRegister.txtPassword.value = "";
  frmRegister.txtPassword2.value = "";
  frmRegister.txtPassword.focus();
}

if (password1 != password2) {
  returnValue = false;
  alert("Your password entries did not match.\nPlease try again.");
  frmRegister.txtPassword.value = "";
  frmRegister.txtPassword2.value = "";
  frmRegister.txtPassword.focus();
}
  return returnValue;
}

But Firefox 5 keeps sending it to register.aspx even though the form doesnt pass the test?

  • 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-05-23T17:21:09+00:00Added an answer on May 23, 2026 at 5:21 pm

    You haven’t defined frmRegister.

    Internet Explorer will (depending, IIRC, on the version and if you are in quirks mode or not) spew a global variable into existence for every element with an id (and some with a name). Other browsers won’t.

    When you try things like:

    frmRegister.txtPassword.value = "";
    

    The browser will error because frmRegister is undefined so can’t have a .txtPassword.

    When it errors, the script dies and the return statement is never reached.

    Since return is never reached, the submission isn’t canceled, and the form is sent to the server as normal.

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

Sidebar

Related Questions

I have a form, that looks like this (sorry for Haml and the german
I have a form that looks like this : [ enterdata: [______] ; more
I have this select input in my form that I want to access via
I have a question form that I want to validate using jquery. My form
I have a simple form that I want to validate using blur if the
I have a form that i want to validate ( show validation summary, show
I have a form that has target=_blank on submit. I want to validate the
Say you have a web form with some fields that you want to validate
I have a form that validates the email address and I want to be
Okay all, I have a form that I want users to fill out. When

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.