-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
161 lines (144 loc) · 4.69 KB
/
script.js
File metadata and controls
161 lines (144 loc) · 4.69 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
var forms = document.getElementById('forms')
var userName = document.getElementById('user')
var password = document.getElementById('password')
var conPass = document.getElementById('conPassword')
var email = document.getElementById('email')
var conEmail = document.getElementById('conEmail')
var inputUser = document.getElementById('inputUser')
var inputPass = document.getElementById('inputPass')
var inputConPass = document.getElementById('inputConPass')
var inputEmail = document.getElementById('inputEmail')
var inputConEmail = document.getElementById('inputConEmail')
var captc = document.getElementById("captcha");
var userCaptc = document.getElementById("inputCaptcha");
var inputUsCaptcha = document.getElementById('inputUsCaptcha')
var allInput = userName.value + password.value + conPass.value + email.value + conEmail.value + userCaptc.value
console.log(allInput)
var formTrue = false;
function validateEmail(eMail){
var reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(eMail)
}
function captcha(){
var capItem = ['56AbE456', '792hg53AB', '84AHB7n', '24GhBcG8', 'lJGne53', 'jg45AGNc'];
for(i = 0; i < 3; i++){
var a = capItem[Math.floor(Math.random() * capItem.length)];
}
var code = a ;
document.getElementById("captcha").value = code
console.log(code);
}
userName.addEventListener('input', function(){
if(userName.value.length < 6){
inputUser.innerHTML = 'Username Min 6 Character'
inputUser.style.color = 'red'
//console.log(formTrue)
//return false
}else{
inputUser.innerHTML = 'Good'
inputUser.style.color = 'green'
//return true
formTrue = true;
//console.log(formTrue)
}
})
password.addEventListener('input', function(){
if(password.value.length < 6){
inputPass.innerHTML = 'Password Min 6 Character'
inputPass.style.color = 'red'
//formTrue
//return false
}else{
inputPass.innerHTML = 'Good'
inputPass.style.color = 'green'
formTrue = true;
//return true
}
})
conPass.addEventListener('input', function(){
if(password.value !== conPass.value){
inputConPass.innerHTML = 'Password Not Match'
inputConPass.style.color = 'red'
// formTrue
//return false
}else{
inputConPass.innerHTML = 'Password Match'
inputConPass.style.color = 'green'
formTrue = true;
//return true
}
})
email.addEventListener('input', function(){
if(!validateEmail(email.value)){
inputEmail.innerHTML = 'Email Must Be Valid'
inputEmail.style.color = 'red'
// formTrue
return false
}else{
inputEmail.innerHTML = 'Email Valid'
inputEmail.style.color = 'green'
// formTrue = true;
return true
}
})
conEmail.addEventListener('input', function(){
if(email.value !== conEmail.value){
inputConEmail.innerHTML = 'Email Not Match'
inputConEmail.style.color = 'red'
// formTrue
return false
}else{
inputConEmail.innerHTML = 'Email Match'
inputConEmail.style.color = 'green'
// formTrue = true;
return true
}
})
userCaptc.addEventListener('input', function(){
if(captc.value === userCaptc.value){
inputUsCaptcha.innerHTML = 'Yes, You are Human!'
inputUsCaptcha.style.color = 'green'
// formTrue = true;
return true
}else{
inputUsCaptcha.innerHTML = 'No, You are Monster! Please Go!'
inputUsCaptcha.style.color = 'red'
return false
}
})
forms.addEventListener('submit', function(){
var formTrues = false;
if(userName.value === ''){
inputUser.innerHTML = 'Please Insert Your Username!'
inputUser.style.color = 'red'
}else if(userName.value.length < 6){
inputUser.innerHTML = 'Username Min 6 Character'
inputUser.style.color = 'red'
}else if(password.value === ''){
inputPass.innerHTML = 'Please Insert Your Password'
inputPass.style.color = 'red'
}else if(password.value < 6){
inputPass.innerHTML = 'Password Min 6 Character'
inputPass.style.color = 'red'
}else if(password.value !== conPass.value){
inputConPass.innerHTML = 'Password Must Match'
inputConPass.style.color = 'red'
}else if(email.value === ''){
inputEmail.innerHTML = 'Please Insert Your Email Address'
inputEmail.style.color = 'red'
}else if(!validateEmail(email.value)){
inputEmail.innerHTML = 'Your Email Not Valid'
inputEmail.style.color = 'red'
}else if(email.value !== conEmail.value){
inputConEmail.innerHTML = 'Your Email Not Match'
inputConEmail.style.color = 'red'
}else if(userCaptc.value === ''){
inputUsCaptcha.innerHTML = 'Hey If You Human, Please Fill this Field'
inputUsCaptcha.style.color = 'red'
}else if(captc.value !== userCaptc.value){
inputUsCaptcha.innerHTML = 'You are Monster! Please Go!'
inputUsCaptcha.style.color = 'red'
}else{
alert('Hip Hip Hooray! You are Human! Congratulations! Kiss Kiss')
}
})