-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
196 lines (165 loc) · 4.45 KB
/
functions.js
File metadata and controls
196 lines (165 loc) · 4.45 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// JavaScript Document
function shade_input_table(tablename)
{
$("#"+tablename + " tr:odd").css('background-color' , '#cdcdcd');
$("#"+tablename + " tr:even").css('background-color' , '#efefef');
}
function shade_data_table(tablename)
{
$("#"+tablename + " tr:odd").css('background-color' , '#cdcdcd');
$("#"+tablename + " tr:even").css('background-color' , '#efefef');
$("#"+tablename + " tr:first").addClass("tableheading");
}
function check_characters(myemail)
{
var thestr=myemail;
var total=thestr.length;
//var found=false;
for(var mycount=0; mycount<total; mycount++)
{
var checkstr1=thestr.charAt(mycount);
var checkstr=checkstr1.charCodeAt(0);
if((checkstr>47 && checkstr<58) || (checkstr>63 && checkstr<91) || (checkstr>96 && checkstr<123) || (checkstr==46))
{
}
else
{
return false;
}
}
return true;
}
function space_found(thestr)
{
var total=thestr.length;
var found=false;
for(var mycount=0; mycount<total; mycount++)
{
if(thestr[mycount]==" ")
{
found=true;
break;
}
}
return found;
}
function validate_email_click(myemail)
{
//var =document.getElementById("myemail").value;
//check the username and the domain name
var the_split=myemail.split("@");
var total=the_split.length;
if(total !=2)
{
alert("Invalid email address!");
return false;
}
var the_username=the_split[0];
var the_domain=the_split[1];
if(check_characters(myemail)!=true)
{
alert("Invalid email address! Please make sure that all characters inputed are correct");
return false;
}
if(space_found(the_username)==true || space_found(the_domain)==true)
{
alert("Invalid email address! Remove all spaces in your input!");
return false;
}
//check the username
if(the_username.length<2)
{
alert("Invalid email");
return false;
}
if(the_domain.length<2)
{
alert("Invalid email");
return false;
}
//alert("The domain name is " + the_domain);
var the_split2=the_domain.split(".");
var total2=the_split2.length;
//alert("Domain split gave me "+ total2 +" components");
if(total2<2)
{
alert("Invalid email address!");
return false;
}
var mycount=0;
var ok=true;
for(mycount=0; mycount<total2; mycount++)
{
//alert("component " + mycount + " is "+ the_split2[mycount] );
if(the_split2[mycount].length<2)
{
alert("Invalid email address!");
return false;
}
}
return true;
}
function val_date_click(mydate)
{
//var mydate=document.getElementById("mydate").value;
//check if my date is ten characters
if(mydate.length !=10)
{
alert("invalid date entry! please enter a valid date using yyyy-mm-dd eg 2019-12-05");
return false;
}
//split the date into year, month and day
var the_split=mydate.split("-");
var total=the_split.length;
if(total != 3)
{
alert("invalid date entry! please enter a valid date using yyyy-mm-dd eg 2019-12-05");
return false;
}
var the_year=the_split[0];
var the_month=the_split[1];
var the_day=the_split[2];
// 1. theyear has to be four digits 2. the year has to be numeric.
if(the_year.length!=4 || isNaN(the_year))
{
alert("invalid year entry! please enter a valid date using yyyy-mm-dd eg 2019-12-05");
return false;
}
if(the_month.length!=2 || isNaN (the_month) || the_month<1 || the_month>12 )
{
alert("invalid month entry! please enter a valid date using yyyy-mm-dd eg 2019-12-05");
return false;
}
if(the_day.length!=2 || isNaN(the_day))
{
alert("invalid day entry! please enter a valid date using yyyy-mm-dd eg 2019-12-05");
return false;
}
else
{
if(the_day>31)
{
alert("invalid day entry! no month can be greater than 31 days");
return false;
}
if((the_month==4 || the_month==6 || the_month==9 || the_month==11) && the_day>30)
{
alert("invalid day entry! April,june,september and november cannot have more than 30 days. please enter a valid date using yyyy-mm-dd eg 2019-12-05");
return false;
}
if(the_month==2)
{
if(the_year % 4 ==0 && the_day >29 )
{
alert("This is a leap year and feburary cannot be greater than 29 days");
return false;
}
if(the_year % 4 !=0 && the_day >28 )
{
alert("This is not a leap year and feburary cannot be greater than 28 days");
return false;
}
}
}
return true;
}