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 build 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>

<br><br>

<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>
<br><br>

</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

This is the Java forum. Java is an Object Oriented programming language. Javascript is a web-based scripting language.

Oh excuse me, im kinda new :{
sorry,mods please move it.

It's ok. You might be better off just re-posting this in the correct forum, seeing as no mods have moved it yet.

done, actually i thought mods had moved it XD
well now they can delete it :}
btw ,when i first read your nickname i thought its Best-Jew-Since-Joo-Clops XDDD
funny, but irrelevant so sorry :P
thanks,
JC

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.