fix: JavaScript error on signup page (#6788)

#### What type of PR is this?

/area core
/kind bug
/milestone 2.20.x

#### What this PR does / why we need it:

修复注册页面的 JS 错误。

#### Does this PR introduce a user-facing change?

```release-note
None 
```
pull/6797/head
Ryan Wang 2024-10-08 18:28:55 +08:00 committed by GitHub
parent c39f937b5b
commit 2555cbf6ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 15 deletions

View File

@ -152,13 +152,31 @@
</div>
<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", function () {
var password = document.getElementById("password"),
confirm_password = document.getElementById("confirmPassword");
function validatePassword() {
if (password.value != confirm_password.value) {
confirm_password.setCustomValidity("Passwords Don't Match");
} else {
confirm_password.setCustomValidity("");
}
}
password.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
});
</script>
<script th:if="${globalInfo.mustVerifyEmailOnRegistration}" th:inline="javascript">
document.addEventListener("DOMContentLoaded", function () {
function sendRequest() {
return new Promise((resolve, reject) => {
const email = document.getElementById("email").value;
if (!email) {
throw new Error(/*[[#{form.signup.emailCode.send.emptyValidation}]]*/);
throw new Error(/*[[#{form.signup.emailCode.send.emptyValidation}]]*/"");
}
fetch("/signup/send-email-code", {
@ -183,20 +201,6 @@
const emailCodeSendButton = document.getElementById("emailCodeSendButton");
sendVerificationCode(emailCodeSendButton, sendRequest);
var password = document.getElementById("password"),
confirm_password = document.getElementById("confirmPassword");
function validatePassword() {
if (password.value != confirm_password.value) {
confirm_password.setCustomValidity("Passwords Don't Match");
} else {
confirm_password.setCustomValidity("");
}
}
password.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
});
</script>
</form>