-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignment.js
27 lines (22 loc) · 941 Bytes
/
assignment.js
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
const form = document.getElementById('signup-form');
const submitBtn = document.getElementById('submit-btn');
form.addEventListener('input', () => {
const name = document.getElementById('name').value;
const mobile = document.getElementById('mobile').value;
const dob = document.getElementById('dob').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const isValidName = name.trim() !== '';
const isValidMobile = /^[0-9]{10}$/.test(mobile);
const isValidDOB = dob !== '';
const isValidEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
const isValidPassword = password.length >= 6;
if (isValidName && isValidMobile && isValidDOB && isValidEmail && isValidPassword) {
submitBtn.disabled = false;
} else {
submitBtn.disabled = true;
}
});
form.addEventListener('submit', (e) => {
e.preventDefault();
});