Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var attempt = 3;
- function validate(){
- var username = document.getElementById("username").value;
- var password = document.getElementById("password").value;
- if ( username == "root" && password == "root"){ // here is password and username
- sweetAlert ("Login successfully");
- window.location = "success.html";
- return false;
- }
- else{
- attempt --;// Decrementing by one.
- sweetAlert("You have "+attempt+" attempt(s) left.");
- // Disabling fields after 3 attempts.
- if( attempt == 0){
- sweetAlert("Oops...", "You have failed to log in 3 times, Fields have been turned off. Please try again later", "error");
- document.getElementById("username").disabled = true;
- document.getElementById("password").disabled = true;
- document.getElementById("submit").disabled = true;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement