From d3e8342fdbcdb2fc10db88f1a2e8042eec163526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90inh=20Qu=E1=BB=91c=20Ch=C6=B0=C6=A1ng?= Date: Tue, 28 Nov 2023 21:53:28 +0700 Subject: [PATCH] update js register --- .../java/com/bakaqc/flower/dao/OrderDAO.java | 1 + src/main/webapp/js/register.js | 37 +++++++++++++++++++ src/main/webapp/view/user_profile.jsp | 23 +++++------- src/main/webapp/view/user_register.jsp | 20 +++++----- 4 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 src/main/webapp/js/register.js diff --git a/src/main/java/com/bakaqc/flower/dao/OrderDAO.java b/src/main/java/com/bakaqc/flower/dao/OrderDAO.java index e085355..d917bfa 100644 --- a/src/main/java/com/bakaqc/flower/dao/OrderDAO.java +++ b/src/main/java/com/bakaqc/flower/dao/OrderDAO.java @@ -219,6 +219,7 @@ public List historyBuy(int userId) { System.out.println(list); return list; } + public static void main(String[] args) { getInstance().historyBuy(2); diff --git a/src/main/webapp/js/register.js b/src/main/webapp/js/register.js new file mode 100644 index 0000000..c17dae1 --- /dev/null +++ b/src/main/webapp/js/register.js @@ -0,0 +1,37 @@ +const form = document.getElementById('register-form'); +const fullNameInp = document.getElementById('fullname'); +const yearOfBirthInp = document.getElementById('yearOfBirth'); +const addressInp = document.getElementById('address'); +const phoneNumberInp = document.getElementById('phone_number'); +const emailInp = document.getElementById('email'); +const errorMessage = document.getElementById('error-message'); + +form.addEventListener('submit', function (send) { + event.preventDefault(); + + removeExtraSpaces(fullNameInp); + + const emailValue = emailInp.value; + + if (!isValidEmail(emailValue)) { + errorMessage.textContent = 'Email không hợp lệ!'; + emailInp.focus(); + return; + } +}); + +emailInp.addEventListener('input', function () { + removeSpaces(emailInp); +}); + +function removeExtraSpaces(input) { + input.value = input.value.replace(/\s+/g, ' ').trim(); +} + +function isValidEmail(email) { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); +} + +function removeSpaces(input) { + input.value = input.value.replace(/\s/g, ''); +} \ No newline at end of file diff --git a/src/main/webapp/view/user_profile.jsp b/src/main/webapp/view/user_profile.jsp index 70c9b35..ba6eeed 100644 --- a/src/main/webapp/view/user_profile.jsp +++ b/src/main/webapp/view/user_profile.jsp @@ -247,21 +247,11 @@
@@ -300,8 +290,13 @@ - - + + + + diff --git a/src/main/webapp/view/user_register.jsp b/src/main/webapp/view/user_register.jsp index 4ec53b3..422cb42 100644 --- a/src/main/webapp/view/user_register.jsp +++ b/src/main/webapp/view/user_register.jsp @@ -28,40 +28,40 @@

Đăng Kí User

-
+
- +
- +
- +
- +
- +
${errorEmail}
@@ -79,7 +79,7 @@
${errorPass}
- @@ -104,5 +104,7 @@
+ + \ No newline at end of file