Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registration Error

Status
Not open for further replies.

kaycee79

Technical User
Jan 10, 2004
82
GB
When submitting a new user, an error message is appearing;

A Runtime Error has occured.
Do you wish to Debug

Line:67
Error:'document.frmUser.txtUser.txtPassword' is a null or not an object

Line 67 is onSubmit="return VerifyData();">

Can anyone help with this problem?

Thanks in advance

Code:
<!--#include file =&quot;clock.inc&quot;-->


<SCRIPT language=&quot;JavaScript&quot;>
<!--
function formValidateEmail(email) {
    var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
    return regex.test(email);
}
function VerifyFields() {
    var msg=&quot;The following fields appear to be invalid:&quot;;
    var blank=false;
    for(var x=0;x<document.forms[0].length;x++) {
        theObj=document.forms[0].elements[x];
        theType=theObj.type;
        theName=theObj.name;
        theValue=theObj.value;
        if((theType!=&quot;SUBMIT&quot;)&&(theType!=&quot;RESET&quot;)) {
            // check if the field is the Email address and validate
            if((theName==&quot;txtEmailAddress&quot;)&&(!formValidateEmail(theValue))) {
                msg+=&quot;\n* &quot;+theName.substring(3,theName.length);
                blank=true;
            }
            // check the other fields but ignore txtAddress2
            if((theName!=&quot;txtAddress2&quot;)&&(theValue==&quot;&quot;)) {
                msg+=&quot;\n* &quot;+theName.substring(3,theName.length);
                blank=true;
            }
        }
    }
    if(blank) {
        alert(msg);
        return false;
    }
    return true;
}
function VerifyData() {
    if (VerifyFields()) {
        if (document.frmUser.txtPassword.value != document.frmUser.txtVerifyPassword.value) {
            alert (&quot;Your passwords do not match - please reenter&quot;);
            return false;
        } else return true;
    } else return false;
}
//-->
</SCRIPT>
<div id=&quot;content&quot;>
<font face=&quot;Arial&quot;>
<input type=&quot;button&quot; onClick=&quot;document.all.content.style.zoom=(document.all.content.style.zoom==1?2:1);&quot; value=&quot;Change Font Size&quot;>

<title>UK Heart Trust Registration Form</title>
</head>
<body style=&quot;font-family: arial&quot;>

<body bgcolor=&quot;#99CCFF&quot;>


<body onload=&quot;StartClock()&quot; onunload=&quot;KillClock()&quot;>
</font>
<form name=&quot;theClock&quot; action=&quot;adduser.asp&quot; METHOD=&quot;post&quot; onSubmit=&quot;return VerifyData();&quot;>
    <font face=&quot;Arial&quot;>
    <input type=&quot;text&quot; name=&quot;theTime&quot; size=6><% Response.Write Date %><br>


<font face=&quot;Arial&quot;>


<title>UK Heart Trust Registration Form</title>
</head>
<body style=&quot;font-family: arial&quot;>

<body bgcolor=&quot;#99CCFF&quot;>



</font>
<form action=&quot;adduser.asp&quot; METHOD=&quot;post&quot; >



<H1 align=&quot;center&quot;><u>Registration Form</u></H1>




    Title: <SELECT NAME=&quot;txtTitle&quot;>
		<OPTION value=&quot;mr&quot;>Mr</OPTION>
		<OPTION value=&quot;mrs&quot;>Mrs</OPTION>
		<OPTION value=&quot;miss&quot;>Miss</OPTION>
		<OPTION value=&quot;ms&quot;>Ms</OPTION>
		<OPTION value=&quot;master&quot;>Master</OPTION>
		<OPTION value=&quot;doctor&quot;>Doctor</OPTION>
		<OPTION value=&quot;lord&quot;>Lord</OPTION>
		<OPTION value=&quot;sir&quot;>Sir</OPTION>
		
	   </SELECT><BR>
    First Name: <input type=&quot;text&quot; name=&quot;txtFirstName&quot; size=&quot;20&quot; ><br>
    Surname: <input type=&quot;text&quot; name= &quot;txtSurname&quot; size=&quot;20&quot; ><br>
    Address1: <input type=&quot;text&quot; name=&quot;txtAddress1&quot; size=&quot;20&quot;><br>
    Address2: <input type=&quot;text&quot; name=&quot;txtAddress2&quot; size=&quot;20&quot;><br>
    Town: <input type=&quot;text&quot; name=&quot;txtTown&quot; size=&quot;20&quot;><br>
    County: <input type=&quot;text&quot; name=&quot;txtCounty&quot; size=&quot;20&quot; ><br>
    Post Code: <input type=&quot;text&quot; name=&quot;txtPostCode&quot; size=&quot;20&quot; ><br>
    Telephone Number: <input type=&quot;text&quot; name=&quot;txtTelephoneNo&quot; size=&quot;20&quot; ><br>
    Email Address: <input type=&quot;text&quot; name=&quot;txtEmailAddress&quot; size=&quot;20&quot; ><br>
<h3>Login Details</h3>   
    Username: <input type=&quot;text&quot; name=&quot;txtUsername&quot; size=&quot;20&quot;><br>
    Password: <input type=&quot;password&quot; name=&quot;txtPassword&quot; size=&quot;20&quot;><br>
    Verify Password: <input type=&quot;password&quot; name=&quot;txtVerifyPassword&quot; size=&quot;20&quot;><br>
    Secret Question: <input type=&quot;text&quot; name=&quot;txtSecretQuestion&quot; size=&quot;20&quot;> 
    (this is required to remind you of your password just incase you forget it)<BR>    

    <INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;>  <INPUT TYPE=&quot;RESET&quot; VALUE=&quot;Clear&quot;>
</form>
<p>
</font>
<font face=&quot;Comic Sans MS&quot;><i>Registered Charity - 00006257</i></font></p>

<% set pageCount = Server.CreateObject(&quot;MSWC.PageCounter&quot;) %>
<p>
	<font face=&quot;Comic Sans MS&quot;>This page has been accessed <%= pageCount.pageHit %> times.</font><font face=&quot;Arial&quot;>
</div>
</font>
</body>
</html>
 
Your form name is not &quot;frmUser&quot; it is unnamed. The only way to reference it is through the document.forms[] array. Hence, since you already have a form defined above it called &quot;theClock&quot;, you will need to use:
Code:
document.forms[1].txtPassword.value
instead.

Hope this helps.

Pete.


Web Developer / Aptrix CMS (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
This chunk of code is where your error is being thrown (specifically the bolded line):

Code:
function VerifyData() {
  if (VerifyFields()) {
Code:
if (document.frmUser.txtPassword.value != document.frmUser.txtVerifyPassword.value) {
Code:
      alert (&quot;Your passwords do not match - please reenter&quot;);
      return false;
    } else return true;
  } else return false;
}

The reason you are getting this error is because there is no form on your HTML page called &quot;frmUser&quot;.

The code you pasted seems to include several body tags, and several head tags. Have a look at the html code, tidy it up (remove the incorrectly placed tags) and set the name of the form to match the name used in your function.

Hope that gets you started,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top