I have solved it myself! using the answer of Biochemist_HK and making it work:
var usernamecheck="name";
var passcheck="password";
var username=prompt ('Enter Username',' ');
var password=prompt ('Enter Password',' ');
//create a counter var
var counter = 2;
//Next create a for loop to loop 3 times then if still the credidentials
//are incorrect then send user to google.com
for (var i = 0; i < counter; i++){
if
(username+password==usernamecheck+passcheck);
else {
alert("The username or password you have entered is incorrect. Please try again.");
var username=prompt ('Enter Username',' ');
var password=prompt ('Enter Password',' ');
}
}
if
(username+password==usernamecheck+passcheck);
else //tells user that the username or password they have entered is wrong and will be sent to google.co.nz
{alert("The username or password you have entered is incorrect. You will now be directed to another webpage.");
{window.location="http://www.google.co.nz"};};
Thanks for the ones who replied. :)