-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
176 lines (176 loc) · 4.24 KB
/
common.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
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
function popuphelp(url)
{
var hWnd = window.open(url,"RePORTERHelp","width=650,height=400,resizable=no,scrollbars=yes");
if (hWnd.focus != null) hWnd.focus();
}
function stripAlphaNumericComma(strInput)
{
var strOutput = new String(strInput);
//strOutput = strOutput.replace(/[^0-9a-zA-Z, (),-]/g, '');
//strOutput=strOutput.replace(/(/g, "");
//strOutput=strOutput.replace(/)/g, "");
strOutput=strOutput.replace(/</g, "");
strOutput=strOutput.replace(/>/g, "");
//strOutput=strOutput.replace(/&/g, "&");
//strOutput=strOutput.replace(/--/g, "");
//strOutput=strOutput.replace(/*/g, "");
strOutput=strOutput.replace(/'/g, "");
//strOutput=strOutput.replace(/"/g, "");
strOutput=strOutput.replace(/%/g, "");
strOutput=strOutput.replace(/#/g, "");
//strOutput=strOutput.replace(/;/g, "");
//strOutput=strOutput.replace(/./g, "");
//strOutput=strOutput.replace(/alert/g, "");
//strOutput=strOutput.replace(/.js/g, "");
return strOutput;
}
//New Code added by SN on 17th Feb
function cc()
{
var url = window.location.pathname
var jsfilename = url.substring(url.lastIndexOf('/')+1);
//alert(jsfilename);
//alert(document.cookie)
/* check for a cookie */
if (jsfilename=="reporter.cfm")
{
if (document.cookie == "")
{
/* if a cookie is not found - alert user -
change cookieexists field value to false */
// alert("COOKIES need to be enabled!");
document.getElementById('cookDiv').style.display = 'block';
} else {
// alert("COOKIES enabled!");
document.getElementById('cookDiv').style.display = 'none';
}
}
}
document.cookie = 'Exist'
//Fn to check blank spaces
function cutSpaces(s)
{
//alert(s)
var s1, x;
x = s1 = "";
l = s.length;
for(i = 0; i < l; i++)
if((x = s.charAt(i)) != " ")
s1+=x;
return s1;
}
function cutats(s)
{
var s1, x;
x = s1 = "";
l = s.length;
for(i = 0; i < l; i++)
if((x = s.charAt(i)) != "@")
s1+=x;
return s1;
}
// New function to check date is valid
function isDate(sDate)
{
var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/
if (re.test(sDate)) {
var dArr = sDate.split("/");
var d = new Date(sDate);
return d.getMonth() + 1 == dArr[0] && d.getDate() == dArr[1] && d.getFullYear() == dArr[2];
}
else {
return false;
}
}
function special_email(var1)
{
if (var1.indexOf('`') >= 0 || var1.indexOf('~') >= 0 || var1.indexOf('!') >= 0 || var1.indexOf('#') >= 0 ||
var1.indexOf('$') >= 0 || var1.indexOf('%') >= 0 || var1.indexOf('^') >= 0 || var1.indexOf('&') >= 0 ||
var1.indexOf('*') >= 0 || var1.indexOf('(') >= 0 || var1.indexOf(')') >= 0 || var1.indexOf('+') >= 0 ||
var1.indexOf('{') >= 0 || var1.indexOf('}') >= 0 || var1.indexOf('|') >= 0 || var1.indexOf('[') >= 0 ||
var1.indexOf(']') >= 0 || var1.indexOf('\\') >= 0 || var1.indexOf(';') >= 0 || var1.indexOf(':') >= 0 ||
var1.indexOf('>') >= 0 || var1.indexOf('<') >= 0 || var1.indexOf(',') >= 0 || var1.indexOf('?') >= 0 ||
var1.indexOf('/') >= 0 || var1.indexOf('\'') >= 0 || var1.indexOf('"') >= 0 || var1.indexOf(' ') >= 0)
{
alert("Enter a valid email address");
return false;
}
return true;
}
function fnValidemail(js_elm)
{
//alert("in")
//alert(js_elm)
email = js_elm.value
// alert(email)
if (cutSpaces(email) == "")
{
alert("Please enter email address");
js_elm.focus();
return false;
}
if (cutSpaces(email) != "")
{
flag=special_email(email);
if(flag==false)
{
js_elm.focus();
return false;
}
var x;
x = email.indexOf("@");
if (email.indexOf("@") <= 0)
{
alert("Invalid email address");
js_elm.value = ""
js_elm.focus();
return false;
}
if (email.substr(email.indexOf("@") - 1, 1) == ".")
{
alert("Invalid email address");
js_elm.value = ""
js_elm.focus();
return false;
}
if (email.indexOf(".") <= 0)
{
alert("Invalid email address");
js_elm.value = ""
js_elm.focus();
return false;
}
if (email.substr(email.length - 2, 1) == "." || email.substr(email.length - 1, 1) == ".")
{
alert("Invalid email address");
js_elm.value = ""
js_elm.focus();
return false;
}
// < 3 chnged to 2
if (email.indexOf(".", email.indexOf("@")) - email.indexOf("@") < 2)
{
alert("Invalid email address.");
//js_elm.value = ""
js_elm.focus();
return false;
}
if (cutats(email).length < email.length - 1)
{
alert("Invalid email address");
js_elm.value = ""
js_elm.focus();
return false;
}
var dom="";
dom=email.substring(email.lastIndexOf("."),email.length)
//alert(dom)
if (email.indexOf(dom)<5)
{
alert("Invalid email address");
js_elm.value = ""
js_elm.focus();
return false;
}
}
}