-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp1.js
More file actions
180 lines (153 loc) · 6.04 KB
/
Copy pathp1.js
File metadata and controls
180 lines (153 loc) · 6.04 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
function verifyName(){
var cname= document.getElementById("cname").value;
let pattern=/^[A-Za-zñáéíóúÑÁÉÍÓÚ]{3,}[ ][A-Za-zñáéíóúÑÁÉÍÓÚ]{3,}$/;
if(cname==""){
return true;
}
else if(pattern.test(cname)){
document.getElementById('formatnamecorrect').innerHTML="The format is correct";
return true;
}
else{
return false;
}
}
function verifyLogin(){
var clogin= document.getElementById("clogin").value;
let pattern= /^[0-9a-z]{4,8}$/;
if(clogin==""){
return true;
}
else if(!pattern.test(clogin) || (clogin.length < 4 || clogin.length > 8)){
document.getElementById('formatlogincorrect').innerHTML="";
document.getElementById('formatlogin').innerHTML="Only ASCII lowercase letters and numbers and between 4 and 8 characters.";
return false;
}
else{
document.getElementById('formatlogin').innerHTML="";
document.getElementById('formatlogincorrect').innerHTML="The format is correct";
return true;
}
}
function verifyPasswd(){
var cpasswd= document.getElementById("cpasswd").value;
let pattern= /(?=.*[+,-,*,/])(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{6,12}/;
if(cpasswd==""){
return true;
}
else if(!pattern.test(cpasswd) || (cpasswd.length < 6|| cpasswd.length > 12)){
document.getElementById('formatpasswdcorrect').innerHTML="";
document.getElementById('formatpasswd').innerHTML="It has to contain at least one uppercase letter, one lowercase letter (with no accents), one number, and one symbol from set “+-*/” and between 4 and 8 characters.";
return false;
}
else{
document.getElementById('formatpasswd').innerHTML="";
document.getElementById('formatpasswdcorrect').innerHTML="The format is correct";
return true;
}
}
function verifyDNI(){
var cDNI= document.getElementById("cdni").value;
let pattern= /^[0-7]{1}[0-9]{7}[A-Za-z]{1}$/;
if(cDNI==""){
return true;
}
else if(!pattern.test(cDNI) || cDNI.length!=9){
document.getElementById('formatdni').innerHTML="8 digits starting with a number between 0 and 7 and additional non-accented ASCII letter (e.g., 12345678A).";
document.getElementById('formatdnicorrect').innerHTML="";
return false;
}
else{
document.getElementById('formatdni').innerHTML="";
document.getElementById('formatdnicorrect').innerHTML="The format is correct";
return true;
}
}
function DateHour(){
var today = new Date();
var now = today.toLocaleString();
document.getElementById('cdate').value=now;
}
function Infobrowser(){
let browserLanguage= navigator.language;
let browserPlatform= navigator.platform;
let browserUser= navigator.userAgent;
let browseronLine= navigator.onLine;
let browsercookieEnabled= navigator.cookieEnabled;
document.getElementById('cbrowser').value= "Language: " +browserLanguage.toString()+" Platform: "+browserPlatform.toString()+ " User: "+browserUser.toString()+" On Line: "+browseronLine.toString()+" Cookie Enabled: "+browsercookieEnabled.toString();
}
function checkOnlyOneGenre(){
document.querySelectorAll('#choosegenre input[type=checkbox]').forEach(function(checkElement) {
//no check
$noCheck = document.querySelector("#noCheck");
$noCheck.checked = false;
//yes check
$yesCheck = document.querySelector("#yesCheck");
$yesCheck.checked = false;
});
}
function checkAll() {
document.querySelectorAll('#choosegenre input[type=checkbox]').forEach(function(checkElement) {
checkElement.checked = true;
$noCheck = document.querySelector("#noCheck");
$noCheck.checked = false;
});
}
function uncheckAll() {
document.querySelectorAll('#choosegenre input[type=checkbox]').forEach(function(checkElement) {
checkElement.checked = false;
$noCheck = document.querySelector("#noCheck");
$noCheck.checked = true;
});
}
function methodGET(){
document.getElementById('multipartPost').disabled=true;
if(document.getElementById('GET').checked){
document.getElementById('myfirstform').method= "GET";
}
}
function methodPOST(){
document.getElementById('multipartPost').disabled=false;
if(document.getElementById('POST').checked){
document.getElementById('myfirstform').method= "POST";
}
}
function enctypeMultipart(){
if(document.getElementById('multipartPost').checked){
document.getElementById('myfirstform').enctype= "multipart/form-data";
}
}
function enctypeURL(){
if(document.getElementById('urlencoded').checked){
document.getElementById('myfirstform').enctype= "application/x-www-form-urlencoded";
}
}
function send_form(){
var cname= document.getElementById("cname").value;
var clogin= document.getElementById("clogin").value;
var cpasswd= document.getElementById("cpasswd").value;
var cDNI= document.getElementById("cdni").value;
if(verifyName() || cname==""){
if(verifyLogin() || clogin==""){
if(verifyPasswd() || cpasswd==""){
if(verifyDNI() || cDNI==""){
return true;
}else{
return false;
}
}else{return false;}
}else{return false;}
}else{ return false;
}
}
function resetear(){
document.getElementById('formatnamecorrect').innerHTML="";
document.getElementById('formatlogin').innerHTML="";
document.getElementById('formatlogincorrect').innerHTML="";
document.getElementById('formatpasswdcorrect').innerHTML="";
document.getElementById('formatpasswd').innerHTML="";
document.getElementById('formatdnicorrect').innerHTML="";
document.getElementById('formatdni').innerHTML="";
document.getElementById('myfirstform').reset();
alert("The form has been reset");
}