-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign.html
74 lines (63 loc) · 2.5 KB
/
sign.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/style/style.css">
</head>
<body>
<div id="signbg">
<div class="signup-form">
<a href="/index.html"><span>Go back your home</span></a>
<h2>Sign Up</h2>
<form id="signup-form">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<div class="btn">
<button type="button" id="submit-button">Submit</button>
<button type= "reset" class="btn" id="reset" >RESET</button>
</div>
</form>
</div>
</div>
<script >
document.addEventListener('DOMContentLoaded', function() {
const signUpForm = document.getElementById('signup-form');
const submitButton = document.getElementById('submit-button');
const resultMessage = document.getElementById('result-message');
if (submitButton) {
submitButton.addEventListener('click', function() {
// Simulate form validation (replace with your actual validation logic)
const username = signUpForm.querySelector('#username').value;
const email = signUpForm.querySelector('#email').value;
const password = signUpForm.querySelector('#password').value;
let message = '';
if (username && email && password) {
// Success message
message = 'Sign-up successful!';
} else {
// Error message
message = 'Error: Please fill in all fields.';
}
// Encode the message for URL
const encodedMessage = encodeURIComponent(message);
// Redirect to another page with the result message
window.location.href = 'result.html?message=' + encodedMessage;
});
}
// Prevent the default form submission action
if (signUpForm) {
signUpForm.addEventListener('submit', function(e) {
e.preventDefault();
});
// Hide the result message when the user interacts with the form again
signUpForm.addEventListener('input', function() {
resultMessage.classList.add('hidden');
});
}
});
</script>
</body>
</html>