?? validation.js
字號:
/* * $Id: Action.java 502296 2007-02-01 17:33:39Z niallp $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */function clearErrorMessages(form) { // get field table var table; for (var i = 0; i < form.childNodes.length; i++) { if (form.childNodes[i].tagName != null && form.childNodes[i].tagName.toLowerCase() == 'table') { table = form.childNodes[i]; break; } } if (table == null) { return; } // clear out any rows with an "errorFor" attribute var rows = table.rows; var rowsToDelete = new Array(); if (rows == null){ return; for(var i = 0; i < rows.length; i++) { var r = rows[i]; if (r.getAttribute("errorFor")) { rowsToDelete.push(r); } } // now delete the rows for (var i = 0; i < rowsToDelete.length; i++) { var r = rowsToDelete[i]; table.deleteRow(r.rowIndex); //table.removeChild(rowsToDelete[i]); }}function clearErrorLabels(form) { // set all labels back to the normal class var elements = form.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; var cells = e.parentNode.parentNode.cells; if (cells && cells.length >= 2) { var label = cells[0].getElementsByTagName("label")[0]; if (label) { label.setAttribute("class", "label"); label.setAttribute("className", "label"); //ie hack cause ie does not support setAttribute } } }}function addError(e, errorText) { try { // clear out any rows with an "errorFor" of e.id var row = e.parentNode.parentNode; var table = row.parentNode; var error = document.createTextNode(errorText); var tr = document.createElement("tr"); var td = document.createElement("td"); var span = document.createElement("span"); td.align = "center"; td.valign = "top"; td.colSpan = 2; span.setAttribute("class", "errorMessage"); span.setAttribute("className", "errorMessage"); //ie hack cause ie does not support setAttribute span.appendChild(error); td.appendChild(span); tr.appendChild(td); tr.setAttribute("errorFor", e.id);; table.insertBefore(tr, row); // updat the label too var label = row.cells[0].getElementsByTagName("label")[0]; label.setAttribute("class", "errorLabel"); label.setAttribute("className", "errorLabel"); //ie hack cause ie does not support setAttribute } catch (e) { alert(e); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -