{"id":3188,"date":"2024-04-08T15:58:44","date_gmt":"2024-04-08T15:58:44","guid":{"rendered":"https:\/\/vrai-dev.johnabbott.qc.ca\/?page_id=3188"},"modified":"2024-04-11T23:52:33","modified_gmt":"2024-04-11T23:52:33","slug":"forgot-password","status":"publish","type":"page","link":"https:\/\/vrai.johnabbott.qc.ca\/zh\/forgot-password\/","title":{"rendered":"Forgot Password"},"content":{"rendered":"<style>\n    .email-title {\n        \/* \ttext-align: center; *\/\n        font-weight: bold;\n        font-size: 24px;\n    }\n    \/* New styles for the form *\/\n    .verification-form {\n        border-radius: 12px;\n        padding: 1.8em;\n        margin: 20px auto;\n        width: 50%;\n        border: 1px solid black;\n        box-shadow: 0px 13px 18px -3px rgba(0, 0, 0, 0.1);\n    }\n\n    .verification-form input[type=\"email\"] {\n        color: black;\n        background-color: #f0f0f0;\n        border-radius: 8px;\n        width: 100%\n    }\n\n    .verification-form input[type=\"submit\"] {\n        font-weight: bold;\n        font-size: 18px;\n        border-radius: 8px;\n        background-color: #4472C4;\n        width: 100%;\n        margin-top: 10px;\n    }\n<\/style>\n\n<body>\n<form class=\"verification-form\" id=\"verification-form\" action=\"\">\n    <p class=\"email-title\">\u91cd\u8bbe\u5bc6\u7801<\/p>\n\n    <div class=\"input-control\">\n        <input id=\"verification-email\" type=\"email\" name=\"email\" placeholder=\"\u7535\u5b50\u90ae\u4ef6\" required \/>\n        <div class=\"error\"><\/div>\n    <\/div>\n\n    <p class=\"verification-btn\"><input type=\"submit\" value=\"\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u9a8c\u8bc1\u94fe\u63a5\" \/><\/p>\n<input type=\"hidden\" name=\"trp-form-language\" value=\"zh\"\/><\/form>\n\n<!-- JavaScript code for form validation and submission (similar to login form) -->\n<script>\n    const verificationForm = document.querySelector('#verification-form');\n    const verificationEmail = document.querySelector('#verification-email');\n\n    verificationForm.addEventListener('submit', async (event) => {\n        event.preventDefault();\n        \/\/ Validate email input\n        if (isValidEmail(verificationEmail.value.trim())) {\n            \/\/ Proceed with sending verification link (add your logic here)\n            console.log('Sending email verification link');\n            \/\/ const email = verificationEmail.value.trim();\n            \/\/ You can use Fetch API or any other method to send the email verification link\n            fetch(`http:\/\/127.0.0.1:3000\/user\/resetPassword`, {\n                method: 'POST',\n                headers: {\n                    'Content-Type': 'application\/json',\n                },\n                body: JSON.stringify({ email: verificationEmail.value })\n            })\n                .then(response => response.json())\n                .then(data => {\n                    if (data.message) {\n                        alert(data.message);\n                    } else {\n                        throw new Error('No response message received');\n                    }\n                })\n                .catch((error) => {\n                    console.error('Error:', error);\n                    alert('Error sending password reset email. Please try again.'); \/\/ Error message\n                });\n        } else {\n            setError(verificationEmail, 'Please provide a valid email address');\n        }\n    });\n\n    function isValidEmail(email) {\n        var regex = \/^([a-zA-Z0-9_.+-])+\\@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$\/;\n        return regex.test(email);\n    }\n\n    const setError = (element, message) => {\n        const inputControl = element.parentElement;\n        const errorDisplay = inputControl.querySelector('.error');\n\n        errorDisplay.innerText = message;\n        inputControl.classList.add('error');\n    }\n<\/script>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>\u91cd\u8bbe\u5bc6\u7801<\/p>","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"wp-custom-template-page-banner-removed","meta":{"footnotes":""},"class_list":["post-3188","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/pages\/3188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/comments?post=3188"}],"version-history":[{"count":16,"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/pages\/3188\/revisions"}],"predecessor-version":[{"id":3242,"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/pages\/3188\/revisions\/3242"}],"wp:attachment":[{"href":"https:\/\/vrai.johnabbott.qc.ca\/zh\/wp-json\/wp\/v2\/media?parent=3188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}