Project

General

Profile

metacat / lib / style / skins / default / include_advancedsearch.jsp @ 3671

1
<%@ page     language="java" %>
2
<!--
3
/**
4
  *  '$RCSfile$'
5
  *      Authors:     Duane Costa
6
  *      Copyright:   2005 University of New Mexico and
7
  *                   Regents of the University of California and the
8
  *                   National Center for Ecological Analysis and Synthesis
9
  *      For Details: http://www.nceas.ucsb.edu/
10
  *
11
  *   '$Author: costa $'
12
  *     '$Date: 2007-02-23 15:29:45 -0800 (Fri, 23 Feb 2007) $'
13
  * '$Revision: 3184 $'
14
  * 
15
  * This program is free software; you can redistribute it and/or modify
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation; either version 2 of the License, or
18
  * (at your option) any later version.
19
  *
20
  * This program is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
  * along with this program; if not, write to the Free Software
27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
  *
29
  */
30
-->
31
<%@ include file="settings.jsp"%>
32
<%@ include file="session_vars.jsp"%>
33
<!-- *********************** START SEARCHBOX TABLE ************************* -->
34
<html>
35
<head>
36
  <title>Metacat Data Catalog Advanced Search Page</title>
37
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
38
  <link href="<%=relativeRoot%>/default.css" rel="stylesheet" type="text/css">
39

    
40
  <script language="javascript" 
41
    type="text/javascript" src="<%=relativeRoot%>/default.js">
42
  </script>
43

    
44
  <script language="javascript" type="text/javascript">
45

    
46
      function trim(stringToTrim) {
47
        return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
48
      }
49

    
50
      function submitRequest(form) {
51
        var canSearch = true;
52
        var x_range = document.map.get_x_range();
53
        var y_range = document.map.get_y_range();
54
        var x_index = x_range.indexOf(' ');
55
        var y_index = y_range.indexOf(' ');
56
        var x_length = x_range.length();
57
        var y_length = y_range.length();
58
        var x_lo = x_range.substring(0, x_index);
59
        var x_hi = x_range.substring(x_index + 1, x_length);
60
        var y_lo = y_range.substring(0, y_index);
61
        var y_hi = y_range.substring(y_index + 1, y_length);
62

    
63
        if (trim(form.subjectValue.value) == "" &&
64
            trim(form.creatorSurname.value) == "" &&
65
            trim(form.creatorOrganization.value) == "" &&
66
            trim(form.locationName.value) == "" &&
67
            (x_range == "-180.0 180.0") &&
68
            (y_range == "-90.0 90.0") &&            
69
            trim(form.taxon.value) == "" &&
70
            form.siteValue.value == "ALLSITES"
71
           ) {              
72
          canSearch = 
73
             confirm("Show *all* data in the catalog?\n(This may take some time!)");
74
        }
75

    
76
        if (canSearch) {        
77
          // Re-initialize the hidden form values prior to submitting
78
          form.northBound.value = "";
79
          form.southBound.value = "";
80
          form.eastBound.value = "";
81
          form.westBound.value = "";
82

    
83
          if ((x_range != "-180.0 180.0") || (y_range != "-90.0 90.0")) {     
84
            form.northBound.value = y_hi;
85
            form.southBound.value = y_lo;
86
            form.eastBound.value = x_hi;
87
            form.westBound.value = x_lo;
88
          }
89
          
90
          return(validateAdvancedSearchForm(form));
91
        }
92
        else {
93
          return false;
94
        }
95
      }
96
  </script>
97
</head>
98

    
99
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
100
  <table width="750px" align="center" cellspacing="0" cellpadding="0">
101
    <tr> 
102
      <td width="10" align="right" valign="top">
103
        <img src="<%=relativeRoot%>/images/panelhead_bg_lcorner.gif" 
104
          width="10" height="21">
105
      </td>
106
      <td class="sectionheader">
107
        advanced search 
108
      </td>
109
      <td width="10" align="left" valign="top"> 
110
        <img src="<%=relativeRoot%>/images/panelhead_bg_rcorner.gif" 
111
          width="10" height="21">
112
      </td>
113
    </tr>
114
    <tr> 
115
      <td colspan="3">
116
        <table width="100%" border="0" cellpadding="0" cellspacing="0" 
117
          class="subpanel">
118
          <tr> 
119
            <td colspan="2"></td>
120
          </tr>
121
          <tr valign="baseline"> 
122
            <td colspan="2">
123
    <form name="advancedSearchForm"
124
          method="POST"
125
          action="advancedsearchforward.jsp"
126
          onsubmit="return submitRequest(this)"
127
          target="_top">
128
      <table width="100%" border="0" cellpadding="0" cellspacing="0" >
129
        <tr>
130
          <td colspan="2"><hr/></td>
131
        </tr>
132
        <tr>
133
          <td colspan="2">
134
            <h3>Subject</h3>
135
          </td>
136
        </tr>
137
        <tr>
138
          <td>&nbsp;</td>
139
          <td>&nbsp;</td>
140
        </tr>
141
        <tr>
142
          <td align="right" nowrap>
143
            <select name="subjectField">
144
              <option value="ALL">Subject</option>
145
              <option value="TITLE">Title Only</option>
146
              <option value="ABSTRACT">Abtract Only</option>
147
              <option value="KEYWORDS">Keywords Only</option>
148
            </select>
149
          </td>
150
          <td>
151
            <select name="subjectQueryType">
152
              <option value="0" selected="selected">contains</option>
153
              <option value="1">matches exactly</option>
154
              <option value="2">starts with</option>
155
              <option value="3">ends with</option>
156
            </select>
157
            <input type="text" name="subjectValue" value="">
158
            <input type="radio" name="subjectAllAny" value="0" checked="checked">All Terms
159
            <input type="radio" name="subjectAllAny" value="1">Any Term
160
          </td>
161
        </tr>
162
        <tr>
163
          <td>&nbsp;</td>
164
          <td>&nbsp;</td>
165
        </tr>
166
        <tr>
167
          <td colspan="2"><hr/></td>
168
        </tr>
169
        <tr>
170
          <td colspan="2">
171
            <h3>Author</h3>
172
          </td>
173
        </tr>
174
        <tr>
175
          <td>&nbsp;</td>
176
          <td>&nbsp;</td>
177
        </tr>
178
        <tr>
179
          <td nowrap align="right">Individual's Last Name:
180
          </td>
181
          <td>
182
            <select name="creatorSurnameQueryType">
183
              <option value="0" selected="selected">contains</option>
184
              <option value="1">matches exactly</option>
185
              <option value="2">starts with</option>
186
              <option value="3">ends with</option></select>
187
            <input type="text" name="creatorSurname" value="">
188
          </td>
189
        </tr>
190
        <tr>
191
          <td>&nbsp;</td>
192
          <td>&nbsp;</td>
193
        </tr>
194
        <tr>
195
          <td align="right" nowrap>Organization:
196
          </td>
197
          <td>
198
            <select name="creatorOrganizationQueryType">
199
              <option value="0" selected="selected">contains</option>
200
              <option value="1">matches exactly</option>
201
              <option value="2">starts with</option>
202
              <option value="3">ends with</option></select>
203
            <input type="text" name="creatorOrganization" value="">
204
          </td>
205
        </tr>
206
        <tr>
207
          <td>&nbsp;</td>
208
          <td>&nbsp;</td>
209
        </tr>
210
        <tr>
211
          <td colspan="2"><hr/></td>
212
        </tr>
213
        <tr>
214
          <td colspan="2">
215
            <h3>Spatial Criteria</h3>
216
          </td>
217
        </tr>
218
        <tr>
219
          <td>&nbsp;</td>
220
          <td>&nbsp;</td>
221
        </tr>
222
        <tr>
223
          <td align="right">Geographic Boundaries:</td>
224
        </tr>
225
        <tr>
226
          <td>&nbsp;</td>
227
          <td>
228
            <applet
229
              CODEBASE="@systemidserver@/@context@/LiveMap_30"
230
              CODE="LiveMap_30.class"
231
              ARCHIVE="LiveMap_30.jar"
232
              NAME="map" 
233
              MAYSCRIPT 
234
              width=500 
235
              height=160>
236
              <param name=base_image value="gifs/java_0_world_20k.jpg">
237
              <param name=img_x_domain value="-180 180">
238
              <param name=img_y_domain value="-90 90">
239
              <param name=toolType value="XY">
240
              <param name=tool_x_range value="-180 180">
241
              <param name=tool_y_range value="-90 90">
242
            </applet>
243
          </td>
244
        </tr>
245
        <tr>
246
          <td>&nbsp;</td>
247
          <td>
248
            <!--
249
             The underlying property value associated with checkbox
250
             should be of type boolean, and any value you specify 
251
             should correspond to one of the strings that indicate a 
252
             true value ("true", "yes", or "on").
253
            -->
254
            <input type="checkbox" name="boundaryContained" value="on">
255
            Dataset must be fully contained within boundaries
256
          </td>
257
        </tr>
258
        <tr>
259
          <td>&nbsp;</td>
260
          <td>&nbsp;</td>
261
        </tr>
262
        <tr>
263
          <td align="right">Geographic Place Name: 
264
          </td>
265
          <td><input type="text" name="locationName" value="">
266
          </td>
267
        </tr>
268
        <tr>
269
          <td>&nbsp;</td>
270
          <td>&nbsp;</td>
271
        </tr>
272
        <tr>
273
          <td colspan="2"><hr/></td>
274
        </tr>
275
        <!-- Temporal Criteria section is disabled because Metacat is
276
             not able to search date ranges. An enhancement request has
277
             been entered in Bugzilla (see 
278
             http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2084 )
279
        <tr>
280
          <td colspan="2">
281
            <h3>Temporal Criteria</h3>
282
          </td>
283
        </tr>
284
        <tr>
285
          <td>&nbsp;</td>
286
          <td>&nbsp;</td>
287
        </tr>
288
        <tr>
289
          <td align="right">
290
            <select name="dateField">
291
              <option value="ALL">All Dates</option>
292
              <option value="COLLECTION">Collection Date</option>
293
              <option value="PUBLICATION">Publication Date</option>
294
            </select>
295
          </td>
296
          <td colspan="2">
297
            <input type="text" name="startDate" maxlength="10" size="10" value="" style="font-family:monospace;">
298
            to
299
            <input type="text" name="endDate" maxlength="10" size="10" value="" style="font-family:monospace;">
300
          </td>
301
        </tr>
302
        <tr>
303
          <td>&nbsp;</td>
304
          <td>&nbsp;</td>
305
        </tr>
306
        <tr>
307
          <td align="right">Named Timescale:
308
            <select name="namedTimescaleQueryType">
309
              <option value="0" selected="selected">contains</option>
310
              <option value="1">matches exactly</option>
311
              <option value="2">starts with</option>
312
              <option value="3">ends with</option>
313
            </select>
314
          </td>
315
          <td>
316
            <input type="text" name="namedTimescale" value="">
317
          </td>
318
        </tr>
319
        <tr>
320
          <td>&nbsp;</td>
321
          <td>&nbsp;</td>
322
        </tr>
323
        <tr>
324
          <td colspan="2"><hr/></td>
325
        </tr>
326
        -->
327
        <tr>
328
          <td colspan="2">
329
            <h3>Taxonomic Criteria</h3>
330
          </td>
331
        </tr>
332
        <tr>
333
          <td>&nbsp;</td>
334
          <td>&nbsp;</td>
335
        </tr>
336
        <tr>
337
          <td align="right">Taxon:
338
          </td>
339
          <td>
340
            <select name="taxonQueryType">
341
              <option value="0" selected="selected">contains</option>
342
              <option value="1">matches exactly</option>
343
              <option value="2">starts with</option>
344
              <option value="3">ends with</option>
345
            </select>
346
            <input type="text" name="taxon" value="">
347
          </td>
348
        </tr>
349
        <tr>
350
          <td>&nbsp;</td>
351
          <td>&nbsp;
352
            <input type="hidden" name="siteValue" value="ALLSITES"/>
353
          </td>
354
        </tr>
355

    
356
<!--   
357
    Un-comment the following section to include an input box that allows the
358
    user to restrict the search to a specific LTER site. Obviously, this is
359
    probably useful only within LTER. If uncommenting this section, 
360
    be sure to comment-out the hidden siteValue input above.
361
-->
362
       
363
<!--
364
        <tr>
365
          <td colspan="2"><hr/></td>
366
        </tr>
367
        <tr>
368
          <td colspan="2">
369
            <h3>LTER Site</h3>
370
          </td>
371
        </tr>
372
        <tr>
373
          <td>&nbsp;</td>
374
          <td>&nbsp;</td>
375
        </tr>
376
        <tr>
377
          <td align="right">Limit search to LTER site:</td>
378
          <td>
379
            <select name="siteValue">
380
              <option value="ALLSITES">All LTER Sites</option>
381
              <option value="AND">Andrews LTER</option>
382
              <option value="ARC">Arctic LTER</option>
383
              <option value="BES">Baltimore Ecosystem Study</option>
384
              <option value="BNZ">Bonanza Creek LTER</option>
385
              <option value="CAP">Central Arizona - Phoenix Urban LTER</option>
386
              <option value="CCE">California Current Ecosystem</option>
387
              <option value="CDR">Cedar Creek Natural History Area</option>
388
              <option value="CWT">Coweeta LTER</option>
389
              <option value="FCE">Florida Coastal Everglades LTER</option>
390
              <option value="GCE">Georgia Coastal Ecosystems LTER</option>
391
              <option value="HBR">Hubbard Brook LTER</option>
392
              <option value="HFR">Harvard Forest LTER</option>
393
              <option value="JRN">Jornada Basin LTER</option>
394
              <option value="KBS">Kellogg Biological Station LTER</option>
395
              <option value="KNZ">Konza Prairie LTER</option>
396
              <option value="LNO">LTER Network Office</option>
397
              <option value="LUQ">Luquillo LTER</option>
398
              <option value="MCM">McMurdo Dry Valleys LTER</option>
399
              <option value="MCR">Moorea Coral Reef</option>
400
              <option value="NTL">North Temperate Lakes LTER</option>
401
              <option value="NWT">Niwot Ridge LTER</option>
402
              <option value="PAL">Palmer Station LTER</option>
403
              <option value="PIE">Plum Island Ecosystem LTER</option>
404
              <option value="SBC">Santa Barbara Coastal LTER</option>
405
              <option value="SEV">Sevilleta LTER</option>
406
              <option value="SGS">Shortgrass Steppe</option>
407
              <option value="VCR">Virginia Coastal Reserve LTER</option>
408
            </select>
409
          </td>
410
       </tr>
411
        <tr>
412
          <td>&nbsp;</td>
413
          <td>&nbsp;</td>
414
        </tr>
415
-->
416
        <tr>
417
          <td colspan="2"><hr/></td>
418
        </tr>
419
        <tr>
420
          <td colspan="2">
421
            <h3>Search Options</h3>
422
          </td>
423
        </tr>
424
        <tr>
425
          <td colspan="2" align="center">
426
            <table>
427
              <tr>
428
                <td>
429
                  <input type="radio" name="formAllAny" value="0" checked="checked">"And" all search items&nbsp;
430
                </td>
431
                <td>
432
                  <input type="radio" name="formAllAny" value="1">"Or" all search items&nbsp;
433
                </td>
434
                <td>
435
                  <input type="checkbox" name="caseSensitive" value="on">Case sensitive
436
                </td>
437
              </tr>
438
            </table>
439
          </td>
440
        </tr>
441
        <tr>
442
          <td>&nbsp;</td>
443
          <td>&nbsp;</td>
444
        </tr>
445
        <tr>
446
          <td colspan="2"><hr/></td>
447
        </tr>
448
        <tr>
449
          <td colspan="2" align="center">
450
            <input type="submit" value="Search">&nbsp;&nbsp;
451
            <!-- <input type="reset" value="Reset"> -->
452
          </td>
453
        </tr>
454
      </table>
455
      <input type="hidden" name="northBound" value=""/>
456
      <input type="hidden" name="southBound" value=""/>
457
      <input type="hidden" name="eastBound" value=""/>
458
      <input type="hidden" name="westBound" value=""/>
459
    </form>
460
    
461
    <script type="text/javascript" language="Javascript1.1"> 
462

    
463
    <!-- Begin JavaScript input validation checking code.
464
    var bCancel = false; 
465

    
466
    function validateAdvancedSearchForm(form) {                                                                   
467
        if (bCancel) 
468
            return true; 
469
        else 
470
            var formValidationResult;
471
            formValidationResult = validateFloat(form) && validateFloatRange(form); 
472
            return (formValidationResult == 1);
473
    } 
474

    
475
    function advancedSearchForm_FloatValidations () { 
476
      this.a0 = new Array("westBound", "West Boundary must be a number.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
477
      this.a1 = new Array("eastBound", "East Boundary must be a number.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
478
      this.a2 = new Array("northBound", "North Boundary must be a number.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
479
      this.a3 = new Array("southBound", "South Boundary must be a number.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
480
    } 
481

    
482
    function advancedSearchForm_DateValidations () { 
483
      this.a0 = new Array("startDate", "Start Date must be a date (YYYY-MM-DD).", new Function ("varName", "this.datePattern='yyyy-MM-dd';  return this[varName];"));
484
      this.a1 = new Array("endDate", "End Date must be a date (YYYY-MM-DD).", new Function ("varName", "this.datePattern='yyyy-MM-dd';  return this[varName];"));
485
    } 
486

    
487
    function advancedSearchForm_floatRange () { 
488
      this.a0 = new Array("westBound", "West Boundary must be in the range -180.0 through 180.0.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
489
      this.a1 = new Array("eastBound", "East Boundary must be in the range -180.0 through 180.0.", new Function ("varName", "this.min='-180.0'; this.max='180.0';  return this[varName];"));
490
      this.a2 = new Array("northBound", "North Boundary must be in the range -90.0 through 90.0.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
491
      this.a3 = new Array("southBound", "South Boundary must be in the range -90.0 through 90.0.", new Function ("varName", "this.min='-90.0'; this.max='90.0';  return this[varName];"));
492
    } 
493

    
494
    /**
495
    * Check to see if fields are in a valid float range.
496
    * Fields are not checked if they are disabled.
497
    * <p>
498
    * @param form The form validation is taking place on.
499
    */
500
    function validateFloatRange(form) {
501
        var isValid = true;
502
        var focusField = null;
503
        var i = 0;
504
        var fields = new Array();
505
        var formName = form.getAttributeNode("name"); 
506

    
507
        oRange = eval('new ' + formName.value + '_floatRange()');
508
        for (x in oRange) {
509
            var field = form[oRange[x][0]];
510
            
511
            if ((field.type == 'hidden' ||
512
                field.type == 'text' || field.type == 'textarea') &&
513
                (field.value.length > 0)  &&
514
                 field.disabled == false) {
515
        
516
                var fMin = parseFloat(oRange[x][2]("min"));
517
                var fMax = parseFloat(oRange[x][2]("max"));
518
                var fValue = parseFloat(field.value);
519
                if (!(fValue >= fMin && fValue <= fMax)) {
520
                    if (i == 0) {
521
                        focusField = field;
522
                    }
523
                    fields[i++] = oRange[x][1];
524
                    isValid = false;
525
                }
526
            }
527
        }
528
        if (fields.length > 0) {
529
            focusField.focus();
530
            alert(fields.join('\n'));
531
        }
532
        return isValid;
533
    }
534

    
535

    
536
  /**
537
  * This is a place holder for common utilities used across the javascript validation
538
  *
539
  **/
540

    
541

    
542
    /**
543
    * Check to see if fields are a valid byte.
544
    * Fields are not checked if they are disabled.
545
    * <p>
546
    * @param form The form validation is taking place on.
547
    */
548
    function validateByte(form) {
549
        var bValid = true;
550
        var focusField = null;
551
        var i = 0;
552
        var fields = new Array();
553
        var formName = form.getAttributeNode("name"); 
554
        oByte = eval('new ' + formName.value + '_ByteValidations()');
555

    
556
        for (x in oByte) {
557
            var field = form[oByte[x][0]];
558

    
559
            if ((field.type == 'hidden' ||
560
                field.type == 'text' ||
561
                field.type == 'textarea' ||
562
                field.type == 'select-one' ||
563
                field.type == 'radio')  &&
564
                field.disabled == false) {
565

    
566
                var value = '';
567
                // get field's value
568
                if (field.type == "select-one") {
569
                    var si = field.selectedIndex;
570
                    if (si >= 0) {
571
                        value = field.options[si].value;
572
                    }
573
                } else {
574
                    value = field.value;
575
                }
576

    
577
                if (value.length > 0) {
578
                    if (!isAllDigits(value)) {
579
                        bValid = false;
580
                        if (i == 0) {
581
                            focusField = field;
582
                        }
583
                        fields[i++] = oByte[x][1];
584

    
585
                    } else {
586

    
587
                        var iValue = parseInt(value);
588
                        if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
589
                            if (i == 0) {
590
                                focusField = field;
591
                            }
592
                            fields[i++] = oByte[x][1];
593
                            bValid = false;
594
                        }
595
                    }
596
                }
597

    
598
            }
599
        }
600
        if (fields.length > 0) {
601
           focusField.focus();
602
           alert(fields.join('\n'));
603
        }
604
        return bValid;
605
    }
606

    
607

    
608
    /**
609
    * A field is considered valid if less than the specified maximum.
610
    * Fields are not checked if they are disabled.
611
    * <p>
612
    * <strong>Caution:</strong> Using <code>validateMaxLength</code> on a password field in a 
613
    *  login page gives unnecessary information away to hackers. While it only slightly
614
    *  weakens security, we suggest using it only when modifying a password.</p>
615
    * @param form The form validation is taking place on.
616
    */
617
    function validateMaxLength(form) {
618
        var isValid = true;
619
        var focusField = null;
620
        var i = 0;
621
        var fields = new Array();
622
        var formName = form.getAttributeNode("name"); 
623

    
624
        oMaxLength = eval('new ' + formName.value + '_maxlength()');        
625
        for (x in oMaxLength) {
626
            var field = form[oMaxLength[x][0]];
627

    
628
            if ((field.type == 'hidden' ||
629
                field.type == 'text' ||
630
                field.type == 'password' ||
631
                field.type == 'textarea') &&
632
                field.disabled == false) {
633

    
634
                var iMax = parseInt(oMaxLength[x][2]("maxlength"));
635
                if (field.value.length > iMax) {
636
                    if (i == 0) {
637
                        focusField = field;
638
                    }
639
                    fields[i++] = oMaxLength[x][1];
640
                    isValid = false;
641
                }
642
            }
643
        }
644
        if (fields.length > 0) {
645
           focusField.focus();
646
           alert(fields.join('\n'));
647
        }
648
        return isValid;
649
    }
650

    
651

    
652
    /**
653
    *  Check to see if fields must contain a value.
654
    * Fields are not checked if they are disabled.
655
    * <p>
656
    * @param form The form validation is taking place on.
657
    */
658

    
659
    function validateRequired(form) {
660
        var isValid = true;
661
        var focusField = null;
662
        var i = 0;
663
        var fields = new Array();
664
        var formName = form.getAttributeNode("name");
665

    
666
        oRequired = eval('new ' + formName.value + '_required()');
667

    
668
        for (x in oRequired) {
669
            var field = form[oRequired[x][0]];
670

    
671
            if ((field.type == 'hidden' ||
672
                field.type == 'text' ||
673
                field.type == 'textarea' ||
674
                field.type == 'file' ||
675
                field.type == 'checkbox' ||
676
                field.type == 'select-one' ||
677
                field.type == 'password') &&
678
                field.disabled == false) {
679

    
680
                var value = '';
681
                // get field's value
682
                if (field.type == "select-one") {
683
                    var si = field.selectedIndex;
684
                    if (si >= 0) {
685
                        value = field.options[si].value;
686
                    }
687
                } else if (field.type == 'checkbox') {
688
                    if (field.checked) {
689
                        value = field.value;
690
                    }
691
                } else {
692
                    value = field.value;
693
                }
694

    
695
                if (trim(value).length == 0) {
696

    
697
                    if (i == 0) {
698
                        focusField = field;
699
                    }
700
                    fields[i++] = oRequired[x][1];
701
                    isValid = false;
702
                }
703
            } else if (field.type == "select-multiple") { 
704
                var numOptions = field.options.length;
705
                lastSelected=-1;
706
                for(loop=numOptions-1;loop>=0;loop--) {
707
                    if(field.options[loop].selected) {
708
                        lastSelected = loop;
709
                        value = field.options[loop].value;
710
                        break;
711
                    }
712
                }
713
                if(lastSelected < 0 || trim(value).length == 0) {
714
                    if(i == 0) {
715
                        focusField = field;
716
                    }
717
                    fields[i++] = oRequired[x][1];
718
                    isValid=false;
719
                }
720
            } else if ((field.length > 0) && (field[0].type == 'radio' || field[0].type == 'checkbox')) {
721
                isChecked=-1;
722
                for (loop=0;loop < field.length;loop++) {
723
                    if (field[loop].checked) {
724
                        isChecked=loop;
725
                        break; // only one needs to be checked
726
                    }
727
                }
728
                if (isChecked < 0) {
729
                    if (i == 0) {
730
                        focusField = field[0];
731
                    }
732
                    fields[i++] = oRequired[x][1];
733
                    isValid=false;
734
                }
735
            }
736
        }
737
        if (fields.length > 0) {
738
           focusField.focus();
739
           alert(fields.join('\n'));
740
        }
741
        return isValid;
742
    }
743
    
744
    // Trim whitespace from left and right sides of s.
745
    function trim(s) {
746
        return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
747
    }
748

    
749

    
750
    /**
751
    * Check to see if fields are a valid integer.
752
    * Fields are not checked if they are disabled.
753
    * <p>
754
    * @param form The form validation is taking place on.
755
    */
756
    function validateInteger(form) {
757
        var bValid = true;
758
        var focusField = null;
759
        var i = 0;
760
        var fields = new Array();
761
        var formName = form.getAttributeNode("name"); 
762

    
763
        oInteger = eval('new ' + formName.value + '_IntegerValidations()');
764
        for (x in oInteger) {
765
            var field = form[oInteger[x][0]];
766

    
767
            if ((field.type == 'hidden' ||
768
                field.type == 'text' ||
769
                field.type == 'textarea' ||
770
                field.type == 'select-one' ||
771
                field.type == 'radio') &&
772
                field.disabled == false) {
773

    
774
                var value = '';
775
                // get field's value
776
                if (field.type == "select-one") {
777
                    var si = field.selectedIndex;
778
                    if (si >= 0) {
779
                        value = field.options[si].value;
780
                    }
781
                } else {
782
                    value = field.value;
783
                }
784

    
785
                if (value.length > 0) {
786

    
787
                    if (!isAllDigits(value)) {
788
                        bValid = false;
789
                        if (i == 0) {
790
                            focusField = field;
791
                        }
792
                        fields[i++] = oInteger[x][1];
793

    
794
                    } else {
795
                        var iValue = parseInt(value);
796
                        if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
797
                            if (i == 0) {
798
                                focusField = field;
799
                            }
800
                            fields[i++] = oInteger[x][1];
801
                            bValid = false;
802
                       }
803
                   }
804
               }
805
            }
806
        }
807
        if (fields.length > 0) {
808
           focusField.focus();
809
           alert(fields.join('\n'));
810
        }
811
        return bValid;
812
    }
813

    
814
    function isAllDigits(argvalue) {
815
        argvalue = argvalue.toString();
816
        var validChars = "0123456789";
817
        var startFrom = 0;
818
        if (argvalue.substring(0, 2) == "0x") {
819
           validChars = "0123456789abcdefABCDEF";
820
           startFrom = 2;
821
        } else if (argvalue.charAt(0) == "0") {
822
           validChars = "01234567";
823
           startFrom = 1;
824
        } else if (argvalue.charAt(0) == "-") {
825
            startFrom = 1;
826
        }
827

    
828
        for (var n = startFrom; n < argvalue.length; n++) {
829
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
830
        }
831
        return true;
832
    }
833

    
834

    
835
    /**
836
    * Check to see if fields are a valid date.
837
    * Fields are not checked if they are disabled.
838
    * <p>
839
    * @param form The form validation is taking place on.
840
    */
841
    function validateDate(form) {
842
       var bValid = true;
843
       var focusField = null;
844
       var i = 0;
845
       var fields = new Array();
846
       var formName = form.getAttributeNode("name"); 
847

    
848
       oDate = eval('new ' + formName.value + '_DateValidations()');
849

    
850
       for (x in oDate) {
851
           var field = form[oDate[x][0]];
852
           var value = field.value;
853
           var datePattern = oDate[x][2]("datePatternStrict");
854
           // try loose pattern
855
           if (datePattern == null)
856
               datePattern = oDate[x][2]("datePattern");
857
           if ((field.type == 'hidden' ||
858
                field.type == 'text' ||
859
                field.type == 'textarea') &&
860
               (value.length > 0) && (datePattern.length > 0) &&
861
                field.disabled == false) {
862
                 var MONTH = "MM";
863
                 var DAY = "dd";
864
                 var YEAR = "yyyy";
865
                 var orderMonth = datePattern.indexOf(MONTH);
866
                 var orderDay = datePattern.indexOf(DAY);
867
                 var orderYear = datePattern.indexOf(YEAR);
868
                 if ((orderDay < orderYear && orderDay > orderMonth)) {
869
                     var iDelim1 = orderMonth + MONTH.length;
870
                     var iDelim2 = orderDay + DAY.length;
871
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
872
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
873
                     if (iDelim1 == orderDay && iDelim2 == orderYear) {
874
                        dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
875
                     } else if (iDelim1 == orderDay) {
876
                        dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
877
                     } else if (iDelim2 == orderYear) {
878
                        dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
879
                     } else {
880
                        dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
881
                     }
882
                     var matched = dateRegexp.exec(value);
883
                     if(matched != null) {
884
                        if (!isValidDate(matched[2], matched[1], matched[3])) {
885
                           if (i == 0) {
886
                               focusField = field;
887
                           }
888
                           fields[i++] = oDate[x][1];
889
                           bValid =  false;
890
                        }
891
                     } else {
892
                        if (i == 0) {
893
                            focusField = field;
894
                        }
895
                        fields[i++] = oDate[x][1];
896
                        bValid =  false;
897
                     }
898
                 } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
899
                     var iDelim1 = orderDay + DAY.length;
900
                     var iDelim2 = orderMonth + MONTH.length;
901
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
902
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
903
                     if (iDelim1 == orderMonth && iDelim2 == orderYear) {
904
                         dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
905
                     } else if (iDelim1 == orderMonth) {
906
                         dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
907
                     } else if (iDelim2 == orderYear) {
908
                         dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
909
                     } else {
910
                         dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
911
                     }
912
                     var matched = dateRegexp.exec(value);
913
                     if(matched != null) {
914
                         if (!isValidDate(matched[1], matched[2], matched[3])) {
915
                             if (i == 0) {
916
                         focusField = field;
917
                             }
918
                             fields[i++] = oDate[x][1];
919
                             bValid =  false;
920
                          }
921
                     } else {
922
                         if (i == 0) {
923
                             focusField = field;
924
                         }
925
                         fields[i++] = oDate[x][1];
926
                         bValid =  false;
927
                     }
928
                 } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
929
                     var iDelim1 = orderYear + YEAR.length;
930
                     var iDelim2 = orderMonth + MONTH.length;
931
                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
932
                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
933
                     if (iDelim1 == orderMonth && iDelim2 == orderDay) {
934
                         dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
935
                     } else if (iDelim1 == orderMonth) {
936
                         dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
937
                     } else if (iDelim2 == orderDay) {
938
                         dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
939
                     } else {
940
                         dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$");
941
                     }
942
                     var matched = dateRegexp.exec(value);
943
                     if(matched != null) {
944
                         if (!isValidDate(matched[3], matched[2], matched[1])) {
945
                             if (i == 0) {
946
                                 focusField = field;
947
                             }
948
                             fields[i++] = oDate[x][1];
949
                             bValid =  false;
950
                         }
951
                     } else {
952
                          if (i == 0) {
953
                              focusField = field;
954
                          }
955
                          fields[i++] = oDate[x][1];
956
                          bValid =  false;
957
                     }
958
                 } else {
959
                     if (i == 0) {
960
                         focusField = field;
961
                     }
962
                     fields[i++] = oDate[x][1];
963
                     bValid =  false;
964
                 }
965
          }
966
       }
967
       if (fields.length > 0) {
968
          focusField.focus();
969
          alert(fields.join('\n'));
970
       }
971
       return bValid;
972
    }
973
    
974
    function isValidDate(day, month, year) {
975
        if (month < 1 || month > 12) {
976
            return false;
977
        }
978
        if (day < 1 || day > 31) {
979
            return false;
980
        }
981
        if ((month == 4 || month == 6 || month == 9 || month == 11) &&
982
            (day == 31)) {
983
            return false;
984
        }
985
        if (month == 2) {
986
            var leap = (year % 4 == 0 &&
987
               (year % 100 != 0 || year % 400 == 0));
988
            if (day>29 || (day == 29 && !leap)) {
989
                return false;
990
            }
991
        }
992
        return true;
993
    }
994

    
995

    
996
    /**
997
    * Check to see if fields are a valid creditcard number based on Luhn checksum.
998
    * Fields are not checked if they are disabled.
999
    * <p>
1000
    * @param form The form validation is taking place on.
1001
    */
1002
    function validateCreditCard(form) {
1003
        var bValid = true;
1004
        var focusField = null;
1005
        var i = 0;
1006
        var fields = new Array();
1007
        var formName = form.getAttributeNode("name");
1008

    
1009
        oCreditCard = eval('new ' + formName.value + '_creditCard()');
1010

    
1011
        for (x in oCreditCard) {
1012
            if ((form[oCreditCard[x][0]].type == 'text' ||
1013
                 form[oCreditCard[x][0]].type == 'textarea') &&
1014
                (form[oCreditCard[x][0]].value.length > 0)  &&
1015
                 form[oCreditCard[x][0]].disabled == false) {
1016
                if (!luhnCheck(form[oCreditCard[x][0]].value)) {
1017
                    if (i == 0) {
1018
                        focusField = form[oCreditCard[x][0]];
1019
                    }
1020
                    fields[i++] = oCreditCard[x][1];
1021
                    bValid = false;
1022
                }
1023
            }
1024
        }
1025
        if (fields.length > 0) {
1026
            focusField.focus();
1027
            alert(fields.join('\n'));
1028
        }
1029
        return bValid;
1030
    }
1031

    
1032
    /**
1033
     * Checks whether a given credit card number has a valid Luhn checksum.
1034
     * This allows you to spot most randomly made-up or garbled credit card numbers immediately.
1035
     * Reference: http://www.speech.cs.cmu.edu/~sburke/pub/luhn_lib.html
1036
     */
1037
    function luhnCheck(cardNumber) {
1038
        if (isLuhnNum(cardNumber)) {
1039
            var no_digit = cardNumber.length;
1040
            var oddoeven = no_digit & 1;
1041
            var sum = 0;
1042
            for (var count = 0; count < no_digit; count++) {
1043
                var digit = parseInt(cardNumber.charAt(count));
1044
                if (!((count & 1) ^ oddoeven)) {
1045
                    digit *= 2;
1046
                    if (digit > 9) digit -= 9;
1047
                };
1048
                sum += digit;
1049
            };
1050
            if (sum == 0) return false;
1051
            if (sum % 10 == 0) return true;
1052
        };
1053
        return false;
1054
    }
1055

    
1056
    function isLuhnNum(argvalue) {
1057
        argvalue = argvalue.toString();
1058
        if (argvalue.length == 0) {
1059
            return false;
1060
        }
1061
        for (var n = 0; n < argvalue.length; n++) {
1062
            if ((argvalue.substring(n, n+1) < "0") ||
1063
                (argvalue.substring(n,n+1) > "9")) {
1064
                return false;
1065
            }
1066
        }
1067
        return true;
1068
    }
1069

    
1070

    
1071
    /**
1072
    * Check to see if fields is in a valid integer range.
1073
    * Fields are not checked if they are disabled.
1074
    * <p>
1075
    * @param form The form validation is taking place on.
1076
    */
1077
    function validateIntRange(form) {
1078
        var isValid = true;
1079
        var focusField = null;
1080
        var i = 0;
1081
        var fields = new Array();
1082
        var formName = form.getAttributeNode("name"); 
1083

    
1084
        oRange = eval('new ' + formName.value + '_intRange()');        
1085
        for (x in oRange) {
1086
            var field = form[oRange[x][0]];
1087
            if (field.disabled == false)  {
1088
                var value = '';
1089
                if (field.type == 'hidden' ||
1090
                    field.type == 'text' || field.type == 'textarea' ||
1091
                    field.type == 'radio' ) {
1092
                    value = field.value;
1093
                }
1094
                if (field.type == 'select-one') {
1095
                    var si = field.selectedIndex;
1096
                    if (si >= 0) {
1097
                        value = field.options[si].value;
1098
                    }
1099
                }
1100
                if (value.length > 0) {
1101
                    var iMin = parseInt(oRange[x][2]("min"));
1102
                    var iMax = parseInt(oRange[x][2]("max"));
1103
                    var iValue = parseInt(value);
1104
                    if (!(iValue >= iMin && iValue <= iMax)) {
1105
                        if (i == 0) {
1106
                            focusField = field;
1107
                        }
1108
                        fields[i++] = oRange[x][1];
1109
                        isValid = false;
1110
                    }
1111
                }
1112
            }
1113
        }
1114
        if (fields.length > 0) {
1115
            focusField.focus();
1116
            alert(fields.join('\n'));
1117
        }
1118
        return isValid;
1119
    }
1120

    
1121

    
1122
    /**
1123
    *  Check to see if fields are a valid short.
1124
    * Fields are not checked if they are disabled.
1125
    * <p>
1126
    * @param form The form validation is taking place on.
1127
    */
1128
    function validateShort(form) {
1129
        var bValid = true;
1130
        var focusField = null;
1131
        var i = 0;
1132
        var fields = new Array();
1133
        var formName = form.getAttributeNode("name");
1134

    
1135
        oShort = eval('new ' + formName.value + '_ShortValidations()');
1136

    
1137
        for (x in oShort) {
1138
            var field = form[oShort[x][0]];
1139

    
1140
            if ((field.type == 'hidden' ||
1141
                field.type == 'text' ||
1142
                field.type == 'textarea' ||
1143
                field.type == 'select-one' ||
1144
                field.type == 'radio')  &&
1145
                field.disabled == false) {
1146

    
1147
                var value = '';
1148
                // get field's value
1149
                if (field.type == "select-one") {
1150
                    var si = field.selectedIndex;
1151
                    if (si >= 0) {
1152
                        value = field.options[si].value;
1153
                    }
1154
                } else {
1155
                    value = field.value;
1156
                }
1157

    
1158
                if (value.length > 0) {
1159
                    if (!isAllDigits(value)) {
1160
                        bValid = false;
1161
                        if (i == 0) {
1162
                            focusField = field;
1163
                        }
1164
                        fields[i++] = oShort[x][1];
1165

    
1166
                    } else {
1167

    
1168
                        var iValue = parseInt(value);
1169
                        if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
1170
                            if (i == 0) {
1171
                                focusField = field;
1172
                            }
1173
                            fields[i++] = oShort[x][1];
1174
                            bValid = false;
1175
                        }
1176
                   }
1177
               }
1178
            }
1179
        }
1180
        if (fields.length > 0) {
1181
           focusField.focus();
1182
           alert(fields.join('\n'));
1183
        }
1184
        return bValid;
1185
    }
1186

    
1187

    
1188
    /**
1189
    * Check to see if fields are a valid float.
1190
    * Fields are not checked if they are disabled.
1191
    * <p>
1192
    * @param form The form validation is taking place on.
1193
    */
1194
    function validateFloat(form) {
1195
        var bValid = true;
1196
        var focusField = null;
1197
        var i = 0;
1198
        var fields = new Array();
1199
         var formName = form.getAttributeNode("name");
1200

    
1201
        oFloat = eval('new ' + formName.value + '_FloatValidations()');
1202
        for (x in oFloat) {
1203
            var field = form[oFloat[x][0]];
1204
            
1205
            if ((field.type == 'hidden' ||
1206
                field.type == 'text' ||
1207
                field.type == 'textarea' ||
1208
                field.type == 'select-one' ||
1209
                field.type == 'radio') &&
1210
                field.disabled == false) {
1211
        
1212
                var value = '';
1213
                // get field's value
1214
                if (field.type == "select-one") {
1215
                    var si = field.selectedIndex;
1216
                    if (si >= 0) {
1217
                        value = field.options[si].value;
1218
                    }
1219
                } else {
1220
                    value = field.value;
1221
                }
1222
        
1223
                if (value.length > 0) {
1224
                    // remove '.' before checking digits
1225
                    var tempArray = value.split('.');
1226
                    //Strip off leading '0'
1227
                    var zeroIndex = 0;
1228
                    var joinedString= tempArray.join('');
1229
                    while (joinedString.charAt(zeroIndex) == '0') {
1230
                        zeroIndex++;
1231
                    }
1232
                    var noZeroString = joinedString.substring(zeroIndex,joinedString.length);
1233

    
1234
                    if (!isAllDigits(noZeroString)) {
1235
                        bValid = false;
1236
                        if (i == 0) {
1237
                            focusField = field;
1238
                        }
1239
                        fields[i++] = oFloat[x][1];
1240

    
1241
                    } else {
1242
                    var iValue = parseFloat(value);
1243
                    if (isNaN(iValue)) {
1244
                        if (i == 0) {
1245
                            focusField = field;
1246
                        }
1247
                        fields[i++] = oFloat[x][1];
1248
                        bValid = false;
1249
                    }
1250
                    }
1251
                }
1252
            }
1253
        }
1254
        if (fields.length > 0) {
1255
           focusField.focus();
1256
           alert(fields.join('\n'));
1257
        }
1258
        return bValid;
1259
    }
1260

    
1261

    
1262
    /**
1263
    * Check to see if fields are a valid email address.
1264
    * Fields are not checked if they are disabled.
1265
    * <p>
1266
    * @param form The form validation is taking place on.
1267
    */
1268
    function validateEmail(form) {
1269
        var bValid = true;
1270
        var focusField = null;
1271
        var i = 0;
1272
        var fields = new Array();
1273
        var formName = form.getAttributeNode("name");
1274

    
1275

    
1276
        oEmail = eval('new ' + formName.value + '_email()');
1277

    
1278
        for (x in oEmail) {
1279
            var field = form[oEmail[x][0]];
1280
            if ((field.type == 'hidden' || 
1281
                 field.type == 'text' ||
1282
                 field.type == 'textarea') &&
1283
                (field.value.length > 0) &&
1284
                field.disabled == false) {
1285
                if (!checkEmail(field.value)) {
1286
                    if (i == 0) {
1287
                        focusField = field;
1288
                    }
1289
                    fields[i++] = oEmail[x][1];
1290
                    bValid = false;
1291
                }
1292
            }
1293
        }
1294
        if (fields.length > 0) {
1295
            focusField.focus();
1296
            alert(fields.join('\n'));
1297
        }
1298
        return bValid;
1299
    }
1300

    
1301
    /**
1302
     * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
1303
     * http://javascript.internet.com
1304
     */
1305
    function checkEmail(emailStr) {
1306
       if (emailStr.length == 0) {
1307
           return true;
1308
       }
1309
       var emailPat=/^(.+)@(.+)$/;
1310
       var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
1311
       var validChars="\[^\\s" + specialChars + "\]";
1312
       var quotedUser="(\"[^\"]*\")";
1313
       var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
1314
       var atom=validChars + '+';
1315
       var word="(" + atom + "|" + quotedUser + ")";
1316
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
1317
       var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
1318
       var matchArray=emailStr.match(emailPat);
1319
       if (matchArray == null) {
1320
           return false;
1321
       }
1322
       var user=matchArray[1];
1323
       var domain=matchArray[2];
1324
       if (user.match(userPat) == null) {
1325
           return false;
1326
       }
1327
       var IPArray = domain.match(ipDomainPat);
1328
       if (IPArray != null) {
1329
           for (var i = 1; i <= 4; i++) {
1330
              if (IPArray[i] > 255) {
1331
                 return false;
1332
              }
1333
           }
1334
           return true;
1335
       }
1336
       var domainArray=domain.match(domainPat);
1337
       if (domainArray == null) {
1338
           return false;
1339
       }
1340
       var atomPat=new RegExp(atom,"g");
1341
       var domArr=domain.match(atomPat);
1342
       var len=domArr.length;
1343
       if ((domArr[domArr.length-1].length < 2) ||
1344
           (domArr[domArr.length-1].length > 3)) {
1345
           return false;
1346
       }
1347
       if (len < 2) {
1348
           return false;
1349
       }
1350
       return true;
1351
    }
1352

    
1353
  
1354
    /**
1355
    * Check to see if fields are a valid using a regular expression.
1356
    * Fields are not checked if they are disabled.
1357
    * <p>
1358
    * @param form The form validation is taking place on.
1359
    */
1360
    function validateMask(form) {
1361
        var isValid = true;
1362
        var focusField = null;
1363
        var i = 0;
1364
        var fields = new Array();
1365
        var formName = form.getAttributeNode("name"); 
1366

    
1367
        oMasked = eval('new ' + formName.value + '_mask()');      
1368
        for (x in oMasked) {
1369
            var field = form[oMasked[x][0]];
1370

    
1371
            if ((field.type == 'hidden' ||
1372
                field.type == 'text' ||
1373
                 field.type == 'textarea' ||
1374
                 field.type == 'file') &&
1375
                 (field.value.length > 0) &&
1376
                 field.disabled == false) {
1377

    
1378
                if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
1379
                    if (i == 0) {
1380
                        focusField = field;
1381
                    }
1382
                    fields[i++] = oMasked[x][1];
1383
                    isValid = false;
1384
                }
1385
            }
1386
        }
1387

    
1388
        if (fields.length > 0) {
1389
           focusField.focus();
1390
           alert(fields.join('\n'));
1391
        }
1392
        return isValid;
1393
    }
1394

    
1395
    function matchPattern(value, mask) {
1396
       return mask.exec(value);
1397
    }
1398

    
1399

    
1400
    /**
1401
    * A field is considered valid if greater than the specified minimum.
1402
    * Fields are not checked if they are disabled.
1403
    * <p>
1404
    * <strong>Caution:</strong> Using <code>validateMinLength</code> on a password field in a 
1405
    *  login page gives unnecessary information away to hackers. While it only slightly
1406
    *  weakens security, we suggest using it only when modifying a password.</p>
1407
    * @param form The form validation is taking place on.
1408
    */
1409
    function validateMinLength(form) {
1410
        var isValid = true;
1411
        var focusField = null;
1412
        var i = 0;
1413
        var fields = new Array();
1414
        var formName = form.getAttributeNode("name");
1415

    
1416

    
1417
        oMinLength = eval('new ' + formName.value + '_minlength()');
1418

    
1419
        for (x in oMinLength) {
1420
            var field = form[oMinLength[x][0]];
1421

    
1422
            if ((field.type == 'hidden' ||
1423
                field.type == 'text' ||
1424
                field.type == 'password' ||
1425
                field.type == 'textarea') &&
1426
                field.disabled == false) {
1427

    
1428
                var iMin = parseInt(oMinLength[x][2]("minlength"));
1429
                if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
1430
                    if (i == 0) {
1431
                        focusField = field;
1432
                    }
1433
                    fields[i++] = oMinLength[x][1];
1434
                    isValid = false;
1435
                }
1436
            }
1437
        }
1438
        if (fields.length > 0) {
1439
           focusField.focus();
1440
           alert(fields.join('\n'));
1441
        }
1442
        return isValid;
1443
    }
1444

    
1445
    //End  JavaScript input validation checking code. --> 
1446
    </script>
1447
            </td>
1448
          </tr>
1449
          <tr> 
1450
            <td width="375">&nbsp;</td>
1451
            <td width="365">&nbsp;</td>
1452
          </tr>
1453
        </table>
1454
      </td>
1455
    </tr>
1456
  </table>
1457
</body>
1458
<!-- ************************* END SEARCHBOX TABLE ************************* -->