954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Registration form,where is my mistake

Hi!
We have a project,to make a website in school, so one of the mandatory things is the registration form.
so i can just copy from the example the teacher gave us and add some stuff, but i wanted to practice checking the form, and one of my "missions"(huh i feel so cool) was to check if the password is built by none consecutive letters/numbers I.E:
A1B2C3D4E5 is a valid pass word,
and AAAAAAAA , 1111111111 are not valid.
so this is what i got so far:

<html>
<head>
 <title>reg form</title>

<script type="text/javascript" language="JavaScript">
function testform(theform)
{



  if (theform.pass.value.length<9)
   {

      theform.pass.focus();
 
      theform.pass.select();
 
     alert("password must be longer than 8 chars");
 
      return (false);
 
   }

var go=1;
var numbers="0123456789";
var let="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var chkstr=theform.pass.value;

for (i=0;i<(chkstr.length-1);i++)
{ if ((let.indexOf(chkstr.charAt(i))==-1)&&(let.indexOf(chkstr.charAt(i+1))==-1))
     go =0;
    else if((numbers.indexOf(chkstr.charAt(i))==-1)&&(numbers.indexOf(chkstr.charAt(i+1))==-1))
     go = 0;
}
if (go==0)
{
the form.pass.focus();
the form.pass.select();
alert("PW MUST BE bluhbluh!!!");
return (false);
}

return (true);
}


</script>
</head>

<body  text="black">

<h1><center>Registration For The Cockpit</center></h1>



<form action="register.asp" method=post name="registration" onsubmit="return testform(this)">

<table border="0">
      <tr>
          <td>FirstName:</td>    
   	<td><input type = "text" size = "20" name = "fname"></td> 
</tr> <tr>
   	<td>Username:</td>    
   	<td><input type = "text" size = "20" name = "user"></td>
      </tr><tr>
	<td>Password:</td>   
	<td><input type = "password" size = "20" name = "pass" maxlength= "10"></td>
       </tr>

	 </table>
	<input type="submit" value="sumbit">
	<input type="reset" value="clear">
</form>


</body>
</html>

basically checking the password length works, but when i add the other password check , it doesnt work anymore, (dont mind the register.asp,i dont even know what it means,the teacher said to keep it there,if the form isn't valid it will pop up a message, and if it is valid it will continue to a register asp which doesnt exist)
so my problem is, even if i put not valid password it still continues to the next step instead of popping up a msg...
so there is a fault somewhere in the code which starts from "var numbers "0123456789""
Could you please spot my mistake?
thank you in advance!
JooClop

JooClops
Light Poster
44 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

The problem is on line #37 and #38:

//undefined object -

// it should be theform.pass.focus() instead of:
form.pass.focus();
// theform.pass.select() instead of:
form.pass.select();
essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 

wooohoo!
amazing! thanks man :D

JooClops
Light Poster
44 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You