View Single Post
  #5  
Old 10-05-2009
c0sie c0sie is offline
*SuPeRsTaR mEmBeR*
 
Join Date: Feb 2006
Location: Cheltenham
Posts: 3,294
Default

Right, just need one piece of advice if anyone is able to help??

When I run the above code, and enter a VALID password it shows the alert as below, however, if the password is NOT valid the code just seems to get lost and then I have to close IE.

Does anyone know how I can get past
Code:
if (intValidPassword = 1);
			alert("Your password is valid!")
and then back to the top if the password is invalid?

Thanks

Code:
<script language = "JavaScript">


	function validatePassword()
	{
		//Declare and initilise variables
		var intIncludesAt = 0; //Changes to 1 if an @ sign is found
		var intValidPassword = 0; 
		var intIncludesAt = 0;
		var strPassword = prompt("Please enter a valid password","");
		var intFirstChar = parseInt(strPassword.charAt(0)); //First character of the password
		
		while(intValidPassword == 0)
		{ 	
			for (intCount = 0; intCount < strPassword.length; intCount ++)
			{
				if(strPassword.charAt(intCount) == "@")
				{
					intIncludesAt = 1;
				}
			}
		
			if (strPassword.length >= 6 && intIncludesAt == 1 && intFirstChar == 0) 
			{
				intValidPassword = 1;
			}
		}			
		
		if (intValidPassword = 1);
			alert("Your password is valid!")
	}
</script>
__________________
Previously:
BRCA Micro Section Chairman.
BRCA Micro National Champion.

Currently:
JQ fan.
Bellend.

Forums are better than Facebook groups
Reply With Quote