1 /* Copyright 2016-2017, Huawei Technologies Co., Ltd.
\r
3 * Licensed under the Apache License, Version 2.0 (the "License");
\r
4 * you may not use this file except in compliance with the License.
\r
5 * You may obtain a copy of the License at
\r
7 * http://www.apache.org/licenses/LICENSE-2.0
\r
9 * Unless required by applicable law or agreed to in writing, software
\r
10 * distributed under the License is distributed on an "AS IS" BASIS,
\r
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 * See the License for the specific language governing permissions and
\r
13 * limitations under the License.
\r
16 $.validator.setDefaults({
\r
18 success: function (label) {
\r
19 label.text('').addClass('valid');
\r
21 onfocusin: function (element) {
\r
22 this.lastActive = element;
\r
23 this.addWrapper(this.errorsFor(element)).hide();
\r
24 var tip = $(element).attr('tip');
\r
25 if (tip && $(element).parent().children(".tip").length === 0) {
\r
26 $(element).parent().append("<label class='tip'>" + tip + "</label>");
\r
28 $(element).addClass('highlight');
\r
29 if (this.settings.focusCleanup) {
\r
30 if (this.settings.unhighlight) {
\r
31 this.settings.unhighlight.call(this, element, this.settings.errorClass, this.settings.validClass);
\r
33 this.hideThese(this.errorsFor(element));
\r
36 onfocusout: function (element) {
\r
37 $(element).parent().children(".tip").remove();
\r
38 $(element).removeClass('highlight');
\r
39 this.element(element);
\r