reset.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // js for the reset.html file
  2. $(function() {
  3. console.log('reset.js is working!');
  4. /* -----Validating the new password form in reset.html ---------- */
  5. $(".new-password-form").on("click", '.new-pass-btn', function(event) {
  6. var pass1 = $('#new-password').val();
  7. var pass2 = $('#new-password-conf').val();
  8. console.log(pass1);
  9. console.log(pass2);
  10. if (pass1 === '') {
  11. console.log("Didn't enter password.");
  12. $('#new-password-message1').addClass('message-field').text(
  13. "Please enter a password.");
  14. //don't submit the form
  15. event.preventDefault();
  16. }
  17. if (pass2 === '') {
  18. console.log("Didn't confirm password.");
  19. $('#new-password-message2').addClass('message-field')
  20. .text(
  21. "Please confirm your password.");
  22. //don't submit the form
  23. event.preventDefault();
  24. }
  25. if (pass1 !== '' && pass2 !== '' && pass1 !== pass2) {
  26. console.log("Passwords don't match.");
  27. $('#new-password-message1, #new-password-message2').addClass(
  28. 'message-field').text(
  29. "Passwords don't match.");
  30. //don't submit the form
  31. event.preventDefault();
  32. }
  33. if (pass1 !== '' && pass2 !== '' && pass1 === pass2) {
  34. $('#new-password-message1, #new-password-message2').removeClass(
  35. 'message-field').text(
  36. "");
  37. }
  38. });
  39. });// end of jQuery file