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:

 <title>reg form</title>

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

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

     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);


<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">
   	<td><input type = "text" size = "20" name = "fname"></td> 
</tr> <tr>
   	<td><input type = "text" size = "20" name = "user"></td>
	<td><input type = "password" size = "20" name = "pass" maxlength= "10"></td>

	<input type="submit" value="sumbit">
	<input type="reset" value="clear">


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!

9 Years
Discussion Span
Last Post by JooClops

The problem is on line #37 and #38:

//undefined object -

// it should be theform.pass.focus() instead of:
// theform.pass.select() instead of:
Votes + Comments
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.