Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
update js register
Browse files Browse the repository at this point in the history
  • Loading branch information
bakaqc committed Nov 28, 2023
1 parent fc27da1 commit d3e8342
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/bakaqc/flower/dao/OrderDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public List<HistoryBuy> historyBuy(int userId) {
System.out.println(list);
return list;
}


public static void main(String[] args) {
getInstance().historyBuy(2);
Expand Down
37 changes: 37 additions & 0 deletions src/main/webapp/js/register.js
Original file line number Diff line number Diff line change
@@ -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, '');
}
23 changes: 9 additions & 14 deletions src/main/webapp/view/user_profile.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,11 @@
</div>
<div class="d-flex justify-content-center" style="align-items: center;">
<ul class="pagination mt-3 mb-0">
<li class="disabled page-item">
<a href="#" class="page-link">‹</a>
</li>

<li class="active page-item">
<a href="#" class="page-link">1</a>
</li>
<li class="page-item">
<a href="#" class="page-link">2</a>
</li>
<li class="page-item">
<a href="#" class="page-link">3</a>
</li>
<li class="page-item">
<a href="#" class="page-link">›</a>
</li>

</ul>
</div>
</div>
Expand Down Expand Up @@ -300,8 +290,13 @@
<label for="phone">
<h4>Giới Tính</h4>
</label>

<input type="text" class="form-control" name="phone" id="phone" value="${sessionScope.user.gender.toString() == 'male' ? 'Nam' : 'Nữ'}" style="font-size: 18px;"/>

<select name="gender" class="form-control form-select" aria-label=".form-select-lg example" style="font-size: 18px;">
<option value="male">Nam</option>
<option value="female">Nữ</option>
</select>

<!--<input type="text" class="form-control" name="phone" id="phone" value="${sessionScope.user.gender.toString() == 'male' ? 'Nam' : 'Nữ'}" style="font-size: 18px;"/>-->
</div>
</div>

Expand Down
20 changes: 11 additions & 9 deletions src/main/webapp/view/user_register.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@

<h2 class="fw-bold text-uppercase text-center mb-5">Đăng Kí User</h2>

<form action="register" method="post">
<form id="register-form" action="register" method="post">

<div class="form-outline mb-4">
<label class="form-label" for="form3Example1cg">Họ và Tên</label>
<input name="fullname" type="text" id="form3Example1cg" class="form-control form-control-lg" required value="${fullName}"/>
<input name="fullname" type="text" id="fullname" class="form-control form-control-lg" required value="${fullName}"/>
</div>

<div class="form-outline mb-4">
<label class="form-label" for="form3Example3cg">Năm Sinh</label>
<input name="yearOfBirth" type="number" id="form3Example3cg" min="1900" max="2023" class="form-control form-control-lg" required value="${yearOfBirth}"/>
<input name="yearOfBirth" type="number" id="yearOfBirth" min="1900" max="2023" class="form-control form-control-lg" required value="${yearOfBirth}"/>
</div>

<div class="form-outline mb-4">
<label for="gender">Giới tính<span class="text-danger"></span></label>

<select name="gender" class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
<option value="male">Male (Nam)</option>
<option value="female">Female (Nữ)</option>
<option value="male">Nam</option>
<option value="female">Nữ</option>
</select>
</div>

<div class="form-outline mb-4">
<label class="form-label" for="form3Example4cdg">Địa Chỉ</label>
<input name="address" type="text" id="form3Example4cdg" class="form-control form-control-lg" required value="${address}"/>
<input name="address" type="text" id="address" class="form-control form-control-lg" required value="${address}"/>
</div>

<div class="form-outline mb-4">
<label class="form-label" for="form3Example4cdg">Số Điện Thoại</label>
<input name="phone_number" type="text" id="form3Example4cdg" class="form-control form-control-lg" required value="${phoneNumber}"/>
<input name="phone_number" type="text" id="phone_number" class="form-control form-control-lg" required value="${phoneNumber}"/>
</div>

<div class="form-outline mb-4">
<label class="form-label" for="form3Example3cg">Email</label>
<input name="email" type="text" id="form3Example3cg" class="form-control form-control-lg" required value="${email}"/>
<input name="email" type="text" id="email" class="form-control form-control-lg" required value="${email}"/>
</div>

<div id="error-message" class="text-danger err">${errorEmail}</div>
Expand All @@ -79,7 +79,7 @@
<div id="error-message" class="text-danger err">${errorPass}</div>

<div class="d-flex justify-content-center">
<button type="submit"
<button type="submit"
class="btn btn-success btn-block btn-lg gradient-custom-4 text-body"
style="background-color: orange; font-weight: bold;">Đăng Kí Ngay
</button>
Expand All @@ -104,5 +104,7 @@
</div>

</section>

<script src="<%=request.getContextPath()%>/js/register.js"></script>
</body>
</html>

0 comments on commit d3e8342

Please sign in to comment.