PageSourceSearch

https://servicepro.support/js/validation.js

js servicepro.support collected 2026-10-08 06:55:21 UTC 8,290 bytes, 276 lines download raw bytes

1function validate(demoRequest, page)
2{
3	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
4
5	if (page == "vegas") {
6		if (!validateText(document.getElementById('first-name').value))
7		{
8			alert("The First Name field is required.");
9			document.getElementById('first-name').focus();
10			return (false);
11		}
12
13		if (!validateText(document.getElementById('last-name').value))
14		{
15			alert("The Last Name field is required.");
16			document.getElementById('last-name').focus();
17			return (false);
18		}
19
20		if (!validateText(document.getElementById('organization-name').value))
21		{
22			alert("The Organization Name field is required.");
23			document.getElementById('organization-name').focus();
24			return (false);
25		}
26
27				if (!filter.test(document.getElementById('email').value)) 
28			{
29			alert('Please provide a valid email address.');
30			document.getElementById('email').focus();
31			return false;
32			}
33
34		if (!validateText(document.getElementById('vegas-phone').value))
35		{
36			alert("The Phone Number field is required.");
37			document.getElementById('vegas-phone').focus();
38			return (false);
39		}
40
41		if (!validateText(document.getElementById('subject').value))
42		{
43			alert("The Number of Seats Requested field is required.");
44			document.getElementById('subject').focus();
45			return (false);
46		}
47
48		if (document.getElementById('message').value.length > 2048) {
49			alert('Please enter your comments or questions, under 2048 characters in length.');
50			document.getElementById('message').focus();
51			return false;
52		}
53		var response = grecaptcha.getResponse();
54		if (response.length  == 0)  {
55			alert('Please check the CAPTCHA field.');
56			document.getElementById('example').focus();
57			return false;
58		}
59
60		if (document.getElementById('grecaptcharesponse').value.length  == 0) {
61			alert('Please check the CAPTCHA field.');
62			document.getElementById('grecaptchawidget').focus();
63			return false;
64		}
65	}
66
67	if (page == "contactus") {
68        if (!validateText(document.getElementById('Name').value))
69		{
70			alert("The Name field is required.");
71			document.getElementById('Name').focus();
72			return (false);
73		}
74
75        if (!filter.test(document.getElementById('email').value)) 
76        {
77			alert('Please provide a valid email address.');
78			document.getElementById('email').focus();
79			return false;
80        }
81
82    	if (!validateText(document.getElementById('message').value))
83		{
84			alert("The Your Message field is required.");
85			document.getElementById('message').focus();
86			return (false);
87		}
88
89		if (document.getElementById('message').value.length > 2048) {
90			alert('Please enter your message, under 2048 characters in length.');
91			document.getElementById('message').focus();
92			return false;
93		}
94
95		var response = grecaptcha.getResponse();
96		if (response.length  == 0)  {
97			alert('Please check the CAPTCHA field.');
98			document.getElementById('example').focus();
99			return false;
100		}
101	}
102
103	if (page == "getstarted") {
104	var validationFail = false;
105		if (!validateText(document.getElementById('name').value))
106		{
107			alert("The Name field is required.");
108			document.getElementById('name').focus();
109			validationFail = true;
110			return (false);
111		}
112
113		if (!validateText(document.getElementById('company').value))
114		{
115			alert("The Company field is required.");
116			document.getElementById('company').focus();
117			validationFail = true;
118			return (false);
119		}
120
121                if (!filter.test(document.getElementById('email').value)) 
122        	{
123			alert('Please provide a valid email address.');
124			document.getElementById('email').focus();
125			validationFail = true;
126			return false;
127        	}
128
129		if (document.getElementById('message').value.length > 2048) {
130			alert('Please enter Questions/Comments, under 2048 characters in length.');
131			document.getElementById('message').focus();
132			validationFail = true;
133			return false;
134		}
135		if(validationFail == false){
136		var div1 = document.getElementById('hideme');
137		var div2 = document.getElementById('showme');
138		
139			div1.style.display = "none";
140			div2.style.display = "block";
141			document.getElementById('name').readOnly = true;
142			document.getElementById('company').readOnly = true;
143			document.getElementById('email').readOnly = true;
144			document.getElementById('tel').readOnly = true;
145			document.getElementById('mobile').readOnly = true;
146			document.getElementById('message').readOnly = true;
147			return true;
148		}
149        }
150
151	if (page == "personaldemo") {
152		if (!validateText(document.getElementById('name').value))
153		{
154			alert("The Name field is required.");
155			document.getElementById('name').focus();
156			return (false);
157		}
158
159		if (!validateText(document.getElementById('company').value))
160		{
161			alert("The Company field is required.");
162			document.getElementById('company').focus();
163			return (false);
164		}
165
166                if (!filter.test(document.getElementById('email').value)) 
167        	{
168			alert('Please provide a valid email address.');
169			document.getElementById('email').focus();
170			return false;
171        	}
172
173		if (document.getElementById('Notes').value.length > 2048) {
174			alert('Please enter Questions/Comments, under 2048 characters in length.');
175			document.getElementById('Notes').focus();
176			return false;
177		}
178        }
179
180	if (page == "enduserportal") {
181                if (document.getElementById('forgotpassword').checked == true) {
182			if (!filter.test(document.getElementById('Email').value)) 
183        		{
184				alert('Please provide a valid email address.');
185				document.getElementById('Email').focus();
186				return false;
187        		}
188			//documet.getElementById('mode').value = "forgotpassword";
189		} else {
190			if (!validateTextOrEmail(document.getElementById('Email').value)) 
191	        	{
192				alert('Please provide a user name or email address.');
193				document.getElementById('Email').focus();
194				return false;
195	        	}
196			document.getElementById('mode').value = "login";
197		}
198
199		if (document.getElementById('forgotpassword').checked != true && !validateText(document.getElementById('password').value)) {
200			alert('The Password field is required.');
201			document.getElementById('password').focus();
202			return false;
203		}
204
205		if (window.location.href.indexOf("CampaignClientsA.php") > 0) {
206			document.getElementById('MKTCode').value = "SP-Fall2014-Clients-Active";
207		} else if (window.location.href.indexOf("CampaignClientsL.php") > 0) {
208			document.getElementById('MKTCode').value = "SP-Fall2014-Clients-Lapsed";
209		}
210        }
211}
212
213function validateTextOrEmail(checkStr) {
214        if (checkStr.trim() == "") return false;
215
216	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890.-_@";
217	var allValid = true;
218
219	for (i = 0;  i < checkStr.length;  i++)
220	{
221		ch = checkStr.charAt(i);
222		for (j = 0;  j < checkOK.length;  j++)
223			if (ch == checkOK.charAt(j))
224				break;
225
226		if (checkStr.charCodeAt(i) == 32)
227			break;
228			
229		if (j == checkOK.length)
230		{
231			allValid = false;
232			break;
233		}
234	}
235
236	return allValid;
237}
238
239function validateText(checkStr) {
240        if (checkStr.trim() == "") return false;
241
242	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890.-_";
243	var allValid = true;
244
245	for (i = 0;  i < checkStr.length;  i++)
246	{
247		ch = checkStr.charAt(i);
248		for (j = 0;  j < checkOK.length;  j++)
249			if (ch == checkOK.charAt(j))
250				break;
251
252		if (checkStr.charCodeAt(i) == 32)
253			break;
254			
255		if (j == checkOK.length)
256		{
257			allValid = false;
258			break;
259		}
260	}
261
262	return allValid;
263}
264
265function checkboxChanged() {
266        if (document.getElementById('forgotpassword').checked) {
267		document.getElementById('btnLogin').value = "Send Email";
268		document.getElementById('password').value = "";
269		document.getElementById('mode').value = "forgotpassword";
270		document.getElementById('UserNameOrEmail').innerHTML  = "<strong>Email Address</strong>";
271        } else {
272		document.getElementById('btnLogin').value = "Login";
273		document.getElementById('mode').value = "login";
274		document.getElementById('UserNameOrEmail').innerHTML  = "<strong>User Name or Email Address</strong>";
275        }
276}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.