annotate WebContent/jscripts/tiny_mce/utils/validate.js @ 20:6629e8422760

half baked version for new JWT auth :-(
author casties
date Fri, 23 Mar 2012 21:41:53 +0100
parents 0be9d53a6967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2 * validate.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4 * Copyright 2009, Moxiecode Systems AB
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 * Released under LGPL License.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 * License: http://tinymce.moxiecode.com/license
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 * Contributing: http://tinymce.moxiecode.com/contributing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 // String validation:
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 if (!Validator.isEmail('myemail'))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15 alert('Invalid email.');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17 // Form validation:
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 var f = document.forms['myform'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21 if (!Validator.isEmail(f.myemail))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 alert('Invalid email.');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 var Validator = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 isEmail : function(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30 isAbsUrl : function(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 isSize : function(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 isId : function(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 isEmpty : function(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43 var nl, i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 if (s.type == 'checkbox' && !s.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 if (s.type == 'radio') {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52 for (i=0, nl = s.form.elements; i<nl.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63 isNumber : function(s, d) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 test : function(s, p) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 s = s.nodeType == 1 ? s.value : s;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 return s == '' || new RegExp(p).test(s);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 var AutoValidator = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75 settings : {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 id_cls : 'id',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 int_cls : 'int',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78 url_cls : 'url',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 number_cls : 'number',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 email_cls : 'email',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 size_cls : 'size',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 required_cls : 'required',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83 invalid_cls : 'invalid',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84 min_cls : 'min',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85 max_cls : 'max'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 init : function(s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 var n;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91 for (n in s)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92 this.settings[n] = s[n];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95 validate : function(f) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96 var i, nl, s = this.settings, c = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98 nl = this.tags(f, 'label');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99 for (i=0; i<nl.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100 this.removeClass(nl[i], s.invalid_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 nl[i].setAttribute('aria-invalid', false);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
102 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
103
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
104 c += this.validateElms(f, 'input');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
105 c += this.validateElms(f, 'select');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
106 c += this.validateElms(f, 'textarea');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
107
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
108 return c == 3;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
109 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
110
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
111 invalidate : function(n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
112 this.mark(n.form, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
113 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
114
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
115 getErrorMessages : function(f) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
116 var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
117 nl = this.tags(f, "label");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
118 for (i=0; i<nl.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
119 if (this.hasClass(nl[i], s.invalid_cls)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
120 field = document.getElementById(nl[i].getAttribute("for"));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
121 values = { field: nl[i].textContent };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
122 if (this.hasClass(field, s.min_cls, true)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
123 message = ed.getLang('invalid_data_min');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
124 values.min = this.getNum(field, s.min_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
125 } else if (this.hasClass(field, s.number_cls)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
126 message = ed.getLang('invalid_data_number');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
127 } else if (this.hasClass(field, s.size_cls)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
128 message = ed.getLang('invalid_data_size');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
129 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
130 message = ed.getLang('invalid_data');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
131 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
132
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
133 message = message.replace(/{\#([^}]+)\}/g, function(a, b) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
134 return values[b] || '{#' + b + '}';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
135 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
136 messages.push(message);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
137 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
138 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
139 return messages;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
140 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
141
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
142 reset : function(e) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
143 var t = ['label', 'input', 'select', 'textarea'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
144 var i, j, nl, s = this.settings;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
146 if (e == null)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
147 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
149 for (i=0; i<t.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
150 nl = this.tags(e.form ? e.form : e, t[i]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
151 for (j=0; j<nl.length; j++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
152 this.removeClass(nl[j], s.invalid_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
153 nl[j].setAttribute('aria-invalid', false);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
154 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
155 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
156 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
157
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
158 validateElms : function(f, e) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
159 var nl, i, n, s = this.settings, st = true, va = Validator, v;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
160
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
161 nl = this.tags(f, e);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
162 for (i=0; i<nl.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
163 n = nl[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
164
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
165 this.removeClass(n, s.invalid_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
166
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
167 if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
168 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
169
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
170 if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
171 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
172
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
173 if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
174 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
175
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
176 if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
177 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
178
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
179 if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
180 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
181
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
182 if (this.hasClass(n, s.size_cls) && !va.isSize(n))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
183 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
184
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
185 if (this.hasClass(n, s.id_cls) && !va.isId(n))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
186 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
187
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
188 if (this.hasClass(n, s.min_cls, true)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
189 v = this.getNum(n, s.min_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
190
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
191 if (isNaN(v) || parseInt(n.value) < parseInt(v))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
192 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
193 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
194
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
195 if (this.hasClass(n, s.max_cls, true)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
196 v = this.getNum(n, s.max_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
197
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
198 if (isNaN(v) || parseInt(n.value) > parseInt(v))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
199 st = this.mark(f, n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
200 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
201 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
202
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
203 return st;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
204 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
205
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
206 hasClass : function(n, c, d) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
207 return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
208 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
209
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
210 getNum : function(n, c) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
211 c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
212 c = c.replace(/[^0-9]/g, '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
213
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
214 return c;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
215 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
216
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
217 addClass : function(n, c, b) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
218 var o = this.removeClass(n, c);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
219 n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
220 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
221
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
222 removeClass : function(n, c) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
223 c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
224 return n.className = c != ' ' ? c : '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
225 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
226
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
227 tags : function(f, s) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
228 return f.getElementsByTagName(s);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
229 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
230
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
231 mark : function(f, n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
232 var s = this.settings;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
233
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
234 this.addClass(n, s.invalid_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
235 n.setAttribute('aria-invalid', 'true');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
236 this.markLabels(f, n, s.invalid_cls);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
237
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
238 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
239 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
240
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
241 markLabels : function(f, n, ic) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
242 var nl, i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
243
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
244 nl = this.tags(f, "label");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
245 for (i=0; i<nl.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
246 if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
247 this.addClass(nl[i], ic);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
248 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
249
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
250 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
251 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
252 };