Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> .password-reset-container { max-width: 400px; margin: 40px auto; padding: 30px; background: #fff; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; } .reset-form-header { text-align: center; margin-bottom: 25px; } .reset-form-header h2 { margin: 0; } .form-group { margin-bottom: 20px; } .form-group label { display: block; margin-bottom: 5px; font-weight: 600; } .form-group input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 5px; font-size: 1rem; box-sizing: border-box; } .password-requirements { font-size: 0.8rem; color: #777; margin-top: 5px; } .submit-btn { width: 100%; padding: 12px; background-color: #007bff; border: none; border-radius: 5px; color: white; font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: background-color 0.2s; } .submit-btn:hover { background-color: #0056b3; } </style> <div class="password-reset-container"> <div class="reset-form-header"> <h2>Set a New Password</h2> </div> <form id="passwordResetForm" action="#" method="post"> <div class="form-group"> <label for="new-password">New Password</label> <input type="password" id="new-password" name="new_password" required autocomplete="new-password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number, one uppercase and lowercase letter, and at least 8 or more characters"> <p class="password-requirements">Must contain at least one number, one uppercase and lowercase letter, and at least 8 or more characters.</p> </div> <div class="form-group"> <label for="confirm-password">Confirm New Password</label> <input type="password" id="confirm-password" name="confirm_password" required autocomplete="new-password"> </div> <button type="submit" class="submit-btn">Reset Password</button> </form> </div> <!-- JavaScript for password confirmation --> <script> const resetForm = document.getElementById('passwordResetForm'); const newPassword = document.getElementById('new-password'); const confirmNewPassword = document.getElementById('confirm-password'); resetForm.addEventListener('submit', function(e) { if (newPassword.value !== confirmNewPassword.value) { confirmNewPassword.setCustomValidity('Passwords do not match.'); e.preventDefault(); // Stop form submission } else { confirmNewPassword.setCustomValidity(''); } }); // Clear validation message when user types in the confirm field confirmNewPassword.addEventListener('input', function() { this.setCustomValidity(''); }); </script>