Guest User

Untitled

a guest
Apr 19th, 2017
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var attempt = 3; // Variable to count number of attempts.
  2. // Below function Executes on click of login button.
  3. function validate(){
  4. var username = document.getElementById("username").value;
  5. var password = document.getElementById("password").value;
  6. if ( username == "Formget" && password == "formget#123"){
  7. alert ("Login successfully");
  8. window.location = "success.html"; // Redirecting to other page.
  9. return false;
  10. }
  11. else{
  12. attempt --;// Decrementing by one.
  13. alert("You have left "+attempt+" attempt;");
  14. // Disabling fields after 3 attempts.
  15. if( attempt == 0){
  16. document.getElementById("username").disabled = true;
  17. document.getElementById("password").disabled = true;
  18. document.getElementById("submit").disabled = true;
  19. return false;
  20. }
  21. }
  22. }
Add Comment
Please, Sign In to add comment