PageSourceSearch

https://pskcs.org/scripts/struts/xhtml/validation.js

js pskcs.org collected 2026-09-28 18:49:36 UTC 3,615 bytes, 104 lines download raw bytes

1/*
2 * $Id: validation.javascript,v 1.2 2008/05/07 23:35:56 gmaghera Exp $
3 * ESC-19688 changed file name from validation.javascript to validation.js.
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *  http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23function clearErrorMessages(form) {
24
25    // get field table
26    var table;
27    for (var i = 0; i < form.childNodes.length; i++) {
28        if (form.childNodes[i].tagName != null && form.childNodes[i].tagName.toLowerCase() == 'table') {
29            table = form.childNodes[i];
30            break;
31        }
32    }
33
34    if (table == null) {
35        return;
36    }
37    
38    // clear out any rows with an "errorFor" attribute
39    var rows = table.rows;
40    var rowsToDelete = new Array();
41    if (rows == null){
42        return;
43    }
44
45    for(var i = 0; i < rows.length; i++) {
46        var r = rows[i];
47        if (r.getAttribute("errorFor")) {
48            rowsToDelete.push(r);
49        }
50    }
51
52    // now delete the rows
53    for (var i = 0; i < rowsToDelete.length; i++) {
54        var r = rowsToDelete[i];
55        table.deleteRow(r.rowIndex);
56        //table.removeChild(rowsToDelete[i]); 
57    }
58}
59
60function clearErrorLabels(form) {
61    // set all labels back to the normal class
62    var elements = form.elements;
63    for (var i = 0; i < elements.length; i++) {
64        var e = elements[i];
65        var cells = e.parentNode.parentNode.cells;
66        if (cells && cells.length >= 2) {
67            var label = cells[0].getElementsByTagName("label")[0];
68            if (label) {
69                label.setAttribute("class", "label");
70                label.setAttribute("className", "label"); //ie hack cause ie does not support setAttribute
71            }
72        }
73    }
74
75}
76
77function addError(e, errorText) {
78    try {
79        // clear out any rows with an "errorFor" of e.id
80        var row = e.parentNode.parentNode;
81        var table = row.parentNode;
82        var error = document.createTextNode(errorText);
83        var tr = document.createElement("tr");
84        var td = document.createElement("td");
85        var span = document.createElement("span");
86        td.align = "center";
87        td.valign = "top";
88        td.colSpan = 2;
89        span.setAttribute("class", "errorMessage");
90        span.setAttribute("className", "errorMessage"); //ie hack cause ie does not support setAttribute
91        span.appendChild(error);
92        td.appendChild(span);
93        tr.appendChild(td);
94        tr.setAttribute("errorFor", e.id);;
95        table.insertBefore(tr, row);
96
97        // updat the label too
98        var label = row.cells[0].getElementsByTagName("label")[0];
99        label.setAttribute("class", "errorLabel");
100        label.setAttribute("className", "errorLabel"); //ie hack cause ie does not support setAttribute
101    } catch (e) {
102        alert(e);
103    }
104}

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.