-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
108 lines (101 loc) · 3.37 KB
/
script.js
File metadata and controls
108 lines (101 loc) · 3.37 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
$(".carousel").carousel({
interval: 2000,
});
$("#myTab a").on("click", function (e) {
e.preventDefault();
$(this).tab("show");
});
// signup validation
function validate() {
let username = document.getElementById("username");
let email = document.getElementById("email");
let mobno = document.getElementById("mobno");
let Password = document.getElementById("password");
let Confirm_password = document.getElementById("confirm_password");
let emailerror = document.getElementById("emailerror");
let moberror = document.getElementById("moberror");
let Phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
let emailid =
/^([A-Za-z0-9\.-]+)@([A-Za-z0-9-]+)\.([a-z]{2,3})(.[a-z]{2,3})?$/;
let passwordcheck =
/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{8,})/;
if (
username.value != "" &&
email.value != "" &&
mobno.value != "" &&
Password.value != "" &&
Confirm_password.value != ""
) {
if (emailid.test(email.value)) {
if (Phoneno.test(mobno.value)) {
if (passwordcheck.test(Password.value)) {
if (Password.value == Confirm_password.value) {
alert("All type of validation has done on OnSubmit event.");
return true;
} else {
alert("Passwords Doesnt Match, Please Re-enter :");
return false;
}
} else {
alert(
"Password should be of minimum 8 characters, at least one uppercase, and one lower case, must contain at least one number"
);
return false;
}
} else {
moberror.innerHTML = "Phoneno is invalid";
moberror.style.color = "red";
mobno.style.borderColor = "red";
return false;
}
} else {
emailerror.innerHTML = "Email is invalid";
emailerror.style.color = "red";
email.style.borderColor = "red";
return false;
}
} else {
alert("All fields are required.....!");
return false;
}
}
//login validation
function login_validate() {
let login_emailid = document.getElementById("login_email").value;
let login_passwordid = document.getElementById("login_password").value;
console.log(login_emailid)
let emailid = /^([A-Za-z0-9\.-]+)@([A-Za-z0-9-]+)\.([a-z]{2,3})(.[a-z]{2,3})?$/;
if (login_emailid.value != "" && login_passwordid.value != "") {
const ex = emailid.test(login_emailid)
console.log(ex)
if (emailid.test(login_emailid)) {
alert("All type of validation has done on OnSubmit event.");
return true;
} else {
alert("Email Id is invalid");
return false;
}
} else {
alert("All fields are required.....!");
return false;
}
}
//password strength checker
//
function StrengthChecker() {
let Passwordvalue = document.getElementById("password");
let strengthBadge = document.getElementById("StrengthDisp");
let strongPassword =
/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{8,})/;
let mediumPassword = /(?=.*[a-z])(?=.*[A-Z])(?=.{4,6})/;
if (strongPassword.test(Passwordvalue.value)) {
strengthBadge.style.backgroundColor = "green";
strengthBadge.textContent = "Strong";
} else if (mediumPassword.test(Passwordvalue.value)) {
strengthBadge.style.backgroundColor = "blue";
strengthBadge.textContent = "Medium";
} else {
strengthBadge.style.backgroundColor = "red";
strengthBadge.textContent = "Weak";
}
}