-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (43 loc) 路 1.62 KB
/
Copy pathscript.js
File metadata and controls
53 lines (43 loc) 路 1.62 KB
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
function validateForm() {
const name = document.getElementById('fullname').value.trim();
const email = document.getElementById('email').value.trim();
const phone = document.getElementById('phone').value.trim();
const dob = document.getElementById('dob').value;
const password = document.getElementById('password').value;
const agree = document.getElementById('agree').checked;
const errorMsg = document.getElementById('errorMsg');
errorMsg.innerHTML = "";
if (name === "" || email === "" || phone === "" || password === "" || dob === "") {
errorMsg.innerText = "Please fill out all required fields.";
return false;
}
if (!/^\d{10}$/.test(phone)) {
errorMsg.innerText = "Phone number must be exactly 10 digits.";
return false;
}
if (!agree) {
errorMsg.innerText = "You must agree to the Terms & Conditions.";
return false;
}
alert("馃帀 Registration Successful!");
return true;
}
function previewImage() {
const input = document.getElementById('profilePic');
const preview = document.getElementById('preview');
const file = input.files[0];
if (file) {
preview.src = URL.createObjectURL(file);
preview.style.display = "block";
}
}
function checkPasswordStrength() {
const password = document.getElementById('password').value;
const strengthBar = document.getElementById('strengthBar');
let strength = 0;
if (password.length >= 6) strength += 25;
if (/[A-Z]/.test(password)) strength += 25;
if (/[0-9]/.test(password)) strength += 25;
if (/[\W]/.test(password)) strength += 25;
strengthBar.value = strength;
}