Go Back   oOple.com Forums > General > The PlayGround

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-05-2009
c0sie c0sie is offline
*SuPeRsTaR mEmBeR*
 
Join Date: Feb 2006
Location: Cheltenham
Posts: 3,294
Question Anyone care to help me debug my crappy JavaScript please?

I have to produce a webpage that uses a while{} to ensure that a valid password is entered into a prompt box. Valid passwords include atleast 6 characters, include a @ and begin with the number 0.

Any ideas?

Thanks in advance!!

Code:
<html>
<head>

<script language = "JavaScript">

//Declare and initilise variables
	var intIncludesAt = 0;
	var strPassword = prompt("Please enter a valid password","");
	var intFirstChar;
	var intValidPassword = 0;
	var strCharCheck;

	function validatePassword()
	{
		while(intValidPassword == 0)
		{ 	
			intFirstChar = parseInt(strPassword.charAt(0));
		
			for (intCount=0; intCount<strPassword.length; intCount++)
			{
				if(strPassword.charAt(intCounter) == @)
				{
					intIncludesAt = 1;
				}
			}
		
		if (strPassword.length >= 6 && intintFirstChar == 0 && intIncludesAt == 1)
		{
			intValidPassword = 1;
		}
	}

</script>

</head>

<body>

<input type="button" value="Click here to validate your password" name="cmdValidatePassword" onclick = "validatePassword()">
</body>

</html>
__________________
Previously:
BRCA Micro Section Chairman.
BRCA Micro National Champion.

Currently:
JQ fan.
Bellend.

Forums are better than Facebook groups
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:49 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
oOple.com