Add Email Address To Reset Password
$(document).ready(function () {
let remainingTime = 0;
const timerElement = $('#time-left');
const submitButton = $('#submitBtn');
const emailInput = $('#email');
// Initial state based on remaining time
if (remainingTime>0) {
submitButton.prop('disabled', true); // Disable the button initially
emailInput.prop('readonly', true);
} else {
submitButton.prop('disabled', false); // Enable the button if remaining time > 60 seconds
emailInput.prop('readonly', false);
}
// Update the countdown every second
const timerInterval = setInterval(function () {
if (remainingTime > 0) {
remainingTime--;
timerElement.html('You can resend email after : '+remainingTime + 's');
} else {
// Re-enable the button after 60 seconds
submitButton.prop('disabled', false).text("Resend a Password Reset Email");
submitButton.removeClass('disabled');
emailInput.prop('readonly', false);
clearInterval(timerInterval);
timerElement.html('');
}
}, 1000);
// Disable the submit button after form submission
function disableSubmitButton() {
submitButton.prop('disabled', true);
submitButton.removeClass('disabled').addClass('disabled');
submitButton.text("Envoi... :");
emailInput.prop('readonly', true);
}
// Attach to form submit event
$('form').on('submit', function () {
disableSubmitButton();
});
});