-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
126 lines (118 loc) · 2.99 KB
/
js.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var sub = document.getElementById("submit");
var fname = document.getElementById("fname");
var pass = document.getElementById("pass");
var lname = document.getElementById("lname");
var address = document.getElementById("address");
var mail = document.getElementById("mail");
var phone = document.getElementById("phone");
var accept = 1;
var p=1;
sub.addEventListener("click", function(event){
var ph = phone.value;
function checkph(str) {
return /^01(0|1|2|5)\d{8}$/.test(str);
}
if (isNaN(ph) || !checkph(ph))
{
accept=0;
phone.className = "ac";
myFunction1();
}else{
phone.className = "textBox";
}
var ail=mail.value;
function checker(str) {
return /^\w+(.\w+)?@\w+[.](com|org|edu|net)/i.test(str);
}
if(!checker(ail))
{
accept=0;
mail.className = "ac";
myFunction2();
}else{
mail.className = "textBox";
}
function onlyCap(str) {
return /^[A-Z]+$/.test(str);
}
function containNum(str) {
return /[0-9]/.test(str);
}
function containWhite(str) {
return /[' ']/.test(str);
}
var chars = pass.value.split("");
if (!onlyCap(chars[0])) {
accept=0;
p=0;
myFunction("must start with a capital letter");
}
if(!containNum(chars) )
{
accept = 0;
p=0;
myFunction("password must contain a digit");
}
if(containWhite(chars) )
{
accept = 0;
p=0;
myFunction("remove whitespace");
}
function containsSpecialChars(str) {
const specialChars = /[#&_\-*]/;
return specialChars.test(str);
}
if(!containsSpecialChars(chars)){
accept = 0;
p=0;
myFunction("password must contain *-_&#");
} // pass special
if(p===0)
{
pass.className = "ac";
}
else{
pass.className= "textBox";
}
if(accept === 0 )
{
event.preventDefault();
}
else{
event.href="index.html";
}
accept = 1;
p=1;
}
);
function myFunction(str) {
var popup = document.getElementById("myPopup1");
popup.className="show";
popup.innerHTML=str;
setTimeout(back, 2000);
} function myFunction1() {
var popup = document.getElementById("myPopup2");
popup.className="show";
setTimeout(back2, 2000);
}
function back()
{
var popup = document.getElementById("myPopup1");
popup.className="popuptext";
}
function back2()
{
var popup = document.getElementById("myPopup2");
popup.className="popuptext";
}
function myFunction2() {
var popup = document.getElementById("myPopup3");
popup.className="show";
setTimeout(back3, 2000);
}
function back3()
{
var popup = document.getElementById("myPopup3");
popup.className="popuptext";
}