1 <?xml version=
"1.0" encoding=
"utf-8"?>
3 <xsd:schema id=
"root" xmlns=
"" xmlns:
xsd=
"http://www.w3.org/2001/XMLSchema" xmlns:
msdata=
"urn:schemas-microsoft-com:xml-msdata">
4 <xsd:import namespace=
"http://www.w3.org/XML/1998/namespace" />
5 <xsd:element name=
"root" msdata:
IsDataSet=
"true">
7 <xsd:choice maxOccurs=
"unbounded">
8 <xsd:element name=
"metadata">
11 <xsd:element name=
"value" type=
"xsd:string" minOccurs=
"0" />
13 <xsd:attribute name=
"name" use=
"required" type=
"xsd:string" />
14 <xsd:attribute name=
"type" type=
"xsd:string" />
15 <xsd:attribute name=
"mimetype" type=
"xsd:string" />
16 <xsd:attribute ref=
"xml:space" />
19 <xsd:element name=
"assembly">
21 <xsd:attribute name=
"alias" type=
"xsd:string" />
22 <xsd:attribute name=
"name" type=
"xsd:string" />
25 <xsd:element name=
"data">
28 <xsd:element name=
"value" type=
"xsd:string" minOccurs=
"0" msdata:
Ordinal=
"1" />
29 <xsd:element name=
"comment" type=
"xsd:string" minOccurs=
"0" msdata:
Ordinal=
"2" />
31 <xsd:attribute name=
"name" type=
"xsd:string" use=
"required" msdata:
Ordinal=
"1" />
32 <xsd:attribute name=
"type" type=
"xsd:string" msdata:
Ordinal=
"3" />
33 <xsd:attribute name=
"mimetype" type=
"xsd:string" msdata:
Ordinal=
"4" />
34 <xsd:attribute ref=
"xml:space" />
37 <xsd:element name=
"resheader">
40 <xsd:element name=
"value" type=
"xsd:string" minOccurs=
"0" msdata:
Ordinal=
"1" />
42 <xsd:attribute name=
"name" type=
"xsd:string" use=
"required" />
49 <resheader name=
"resmimetype">
50 <value>text/microsoft-resx
</value>
52 <resheader name=
"version">
55 <resheader name=
"reader">
56 <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=
2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
58 <resheader name=
"writer">
59 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=
2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
61 <data name=
"jsfunctions" xml:
space=
"preserve">
66 Zebda javascript library, version
0.3.1
67 http://labs.cavorite.com/zebda
68 Copyright (C)
2006 Juan Manuel Caicedo
71 - Chris Wilson http://www.christopherwilson.net
73 This library is free software; you can redistribute it and/or
74 modify it under the terms of the GNU Lesser General Public
75 License as published by the Free Software Foundation; either
76 version
2.1 of the License, or (at your option) any later version.
78 This library is distributed in the hope that it will be useful,
79 but WITHOUT ANY WARRANTY; without even the implied warranty of
80 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
81 Lesser General Public License for more details.
83 You should have received a copy of the GNU Lesser General Public
84 License along with this library; if not, write to the Free Software
85 Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA
02110-
1301 USA
88 See http://www.gnu.org/copyleft/lesser.html for more information
98 /*--------------------------------------------------------------------------*/
100 Zebda javascript library
101 http://labs.cavorite.com/zebda
102 Copyright (C)
2006 Juan Manuel Caicedo
104 See zebda.js for full licence
115 parse: function(str){
116 return eval('(' + str + ')');
122 * Removes trailing withspace
124 String.prototype.trim = function(){
125 return this.replace(/ /g, '');
133 * var typeInSet = nodeType in set(
2,
3,
4,
7,
8);
135 * http://laurens.vd.oever.nl/weblog/items2005/setsinjavascript/
139 for (var i =
0; i < arguments.length; i++){
140 result[arguments[i]] = true;
147 * Finds the position of a node
150 Element.getSiblingPosition = function(element){
152 while (element.previousSibling) {
153 if (element.previousSibling.nodeType !=
3){
156 element = element.previousSibling;
166 Element.getParentNodeByName = function(element, tagName){
168 while(par.tagName.toLowerCase() != tagName && par.parentNode) {
169 par = par.parentNode;
176 * @see http://www.litotes.demon.co.uk/example_scripts/fastTableSort_src.html
178 Element.getInnerText = function(element){
179 if (!element || (typeof element).search(/string|undefined/)
> -
1)
182 if (element.innerText)
183 return element.innerText;
186 var nodes = element.childNodes;
187 var len = nodes.length;
188 for (var i =
0; i < len; i++) {
189 switch (nodes[i].nodeType) {
190 case
1: //ELEMENT_NODE
191 rtn += Element.getInnerText(nodes[i]);
194 rtn += nodes[i].nodeValue;
203 * Sets the value of a form field
206 Form.Element.setValue = function(element, value){
207 element = $(element);
208 els = ((element.tagName)) && [element] || element;
210 $A(els).each(function(element){
211 var elmType = element.tagName.toLowerCase();
214 if (typeof(value) != 'object')
217 $A(element.options).each(function(opt){
218 opt.selected = value.include(opt.value);
222 if (element.type in set('radio', 'checkbox')){
223 element.checked = (element.value == value);
225 element.value = value;
232 /*--------------------------------------------------------------------------*/
234 Zebda javascript library
235 http://labs.cavorite.com/zebda
236 Copyright (C)
2006 Juan Manuel Caicedo
238 See zebda.js for full licence
242 var FormValidator = {
251 inlineFilters: false,
252 dateFormat:'m-d-yyyy',
253 thousandSeparator: ',',
254 decimalSeparator: '.'
258 * Load the defined condition and filters
259 * Find all the forms with a validation rule and modify theirs onsubmit function
262 this._definedConditions = [];
263 for (name in FormValidator.Conditions){
264 this._definedConditions.push(name);
267 this._definedFilters = [];
268 for (name in FormValidator.Filters){
269 this._definedFilters.push(name);
272 var forms = $A(document.forms);
274 //Modify onsubmit function for forms with defined rules
275 forms.each(function(f){
277 // attach the validators to the elements on the form
278 FormValidator.initForm(f);
280 f.onsubmit = function(){
283 if (FormValidator.validate(f)){
284 return f.afterValidate();
293 f.originalsubmit = f.submit;
295 f.submit = function(){
306 var disp = f.getAttribute('z:display');
307 f._displayFunction = (FormValidator.Display[disp] || FormValidator.Display.alert);
310 FormValidator.initializeDateCollection();
315 * create a datematch object (js doesn't support named captures...)
318 createDateInfo :function(regex, year, month, day){
319 var dateInfo = new Object;
321 dateInfo.regex = new RegExp(regex);
322 dateInfo.year = year;
323 dateInfo.month = month;
331 * create the date match objects
334 initializeDateCollection: function(){
335 this._datePatterns = [];
337 this._datePatterns[
"dd.mm.yyyy"] = FormValidator.createDateInfo(
"^\([0-3][0-9]\)\\.\([0-1][0-9]\)\\.\([0-9]{4}\)$",
3,
2,
1);
338 this._datePatterns[
"d.m.yyyy"] = FormValidator.createDateInfo(
"^\([0-3]?[0-9]\)\\.\([0-1]?[0-9]\)\\.\([0-9]{4}\)$",
3,
2,
1);
339 this._datePatterns[
"dd/mm/yyyy"] = FormValidator.createDateInfo(
"^\([0-3][0-9]\)\/\([0-1][0-9]\)\/\([0-9]{4}\)$",
3,
2,
1);
340 this._datePatterns[
"d/m/yyyy"] = FormValidator.createDateInfo(
"^\([0-3]?[0-9]\)\/\([0-1]?[0-9]\)\/\([0-9]{4}\)$",
3,
2,
1);
341 this._datePatterns[
"dd-mm-yyyy"] = FormValidator.createDateInfo(
"^\([0-3][0-9]\)\\-\([0-1][0-9]\)\\-\([0-9]{4}\)$",
3,
2,
1);
342 this._datePatterns[
"d-m-yyyy"] = FormValidator.createDateInfo(
"^\([0-3]?[0-9]\)\\-\([0-1]?[0-9]\)\\-\([0-9]{4}\)$",
3,
2,
1);
344 this._datePatterns[
"mm.dd.yyyy"] = FormValidator.createDateInfo(
"^\([0-1][0-9]\)\\.\([0-3][0-9]\)\\.\([0-9]{4}\)$",
3,
1,
2);
345 this._datePatterns[
"m.d.yyyy"] = FormValidator.createDateInfo(
"^\([0-1]?[0-9]\)\\.\([0-3]?[0-9]\)\\.\([0-9]{4}\)$",
3,
1,
2);
346 this._datePatterns[
"mm/dd/yyyy"] = FormValidator.createDateInfo(
"^\([0-1][0-9]\)\/\([0-3][0-9]\)\/\([0-9]{4}\)$",
3,
1,
2);
347 this._datePatterns[
"m/d/yyyy"] = FormValidator.createDateInfo(
"^\([0-1]?[0-9]\)\/\([0-3]?[0-9]\)\/\([0-9]{4}\)$",
3,
1,
2);
348 this._datePatterns[
"mm-dd-yyyy"] = FormValidator.createDateInfo(
"^\([0-21][0-9]\)\\-\([0-3][0-9]\)\\-\([0-9]{4}\)$",
3,
1,
2);
349 this._datePatterns[
"m-d-yyyy"] = FormValidator.createDateInfo(
"^\([0-1]?[0-9]\)\\-\([0-3]?[0-9]\)\\-\([0-9]{4}\)$",
3,
1,
2);
351 this._datePatterns[
"yyyy-mm-dd"] = FormValidator.createDateInfo(
"^\([0-9]{4}\)\\-\([0-1][0-9]\)\\-\([0-3][0-9]\)$",
1,
2,
3);
352 this._datePatterns[
"yyyy/mm/dd"] = FormValidator.createDateInfo(
"^\([0-9]{4}\)\\/\([0-1][0-9]\)\\/\([0-3][0-9]\)$",
1,
2,
3);
353 this._datePatterns[
"yyyy-m-d"] = FormValidator.createDateInfo(
"^\([0-9]{4}\)\\-\([0-1]?[0-9]\)\\-\([0-3]?[0-9]\)$",
1,
2,
3);
354 this._datePatterns[
"yyyy/m/d"] = FormValidator.createDateInfo(
"^\([0-9]{4}\)\\/\([0-1]?[0-9]\)\\/\([0-3]?[0-9]\)$",
1,
2,
3);
363 initForm: function(frm){
367 for (opc in FormValidator.defaultOptions){
368 frm._options[opc] = FormValidator.defaultOptions[opc];
370 opts = eval('(' + frm.getAttribute('z:options') + ')') || {};
372 frm._options[opc] = opts[opc];
375 //Before and after validate functions
376 if (!frm.beforeValidate){
377 func = frm.getAttribute('z:beforeValidate') || 'return true';
378 frm.beforeValidate = new Function(func);
381 if (!frm.afterValidate){
382 func = frm.getAttribute('z:afterValidate') || 'return true';
383 frm.afterValidate = new Function(func);
388 Form.getElements(frm).each(function(elm){
389 FormValidator.Element.init(elm);
390 if (!rtn && FormValidator.Element.hasRules(elm)){
401 validate: function(form){
402 var errs = Form.getElements(form).map(FormValidator.Element.validate).flatten();
403 if (errs.length
> 0){
404 form._displayFunction(errs);
411 * Functions for display errors
417 * Show inline errors.
418 * Based on examples by Cameron Adams:
419 * http://www.themaninblue.com/writing/perspective/
2005/
10/
05/
421 inline: function(errs){
422 $A(document.getElementsByClassName('_zebda_message')).each(function (elm){
423 elm.parentNode.removeChild(elm);
425 errs.map(function(e){
426 var t = document.createElement('span');
427 t.className = '_zebda_message correctionText warning';
428 t.appendChild(document.createTextNode(e.message));
429 e.element.parentNode.insertBefore(t, e.element.nextSibling);
434 * Show an alert with all errors
436 alert: function(errs){
437 alert(errs.pluck('message').join('\n'));
442 * Conditions for the rules
446 required: function(value){
447 return String(value).length
> 0;
450 length: function(value){
452 value = (value || '');
453 if (this.options.max)
454 rtn = (value.length <= this.options.max);
456 if (this.options.min)
457 rtn = rtn && (value.length
>= this.options.min);
462 numeric: function(value){
463 var rtn, val,numberTest;
466 var ts = this.element.form._options.thousandSeparator;
467 var ds = this.element.form._options.decimalSeparator;
469 if(this.options.isFloat)
471 numberTest = new RegExp(
"^-?(\\d*(" + ts +
"?\\d{3})*\\" + ds +
"?\\d+|\\d+(" + ts +
"?\\d{3})*\\" + ds +
"?\\d*)$");
472 if(numberTest.test(value) == false)
475 // remove the thousand separator and replace the decimal separator with an .
476 value = value.replace(new RegExp( ts +
"/g"), String.Empty);
477 value = value.replace(ds,
".");
480 val = parseFloat(value)
484 numberTest = new RegExp(
"^-?\\d*$");
485 if(numberTest.test(value) == false)
487 val = parseInt(value);
493 if (!(this.options.maxValue === undefined))
494 rtn = rtn && (this.options.maxValue
>= val);
496 if (!(this.options.minValue === undefined))
497 rtn = rtn && (val
>= this.options.minValue);
505 regexp: function(value){
506 var reg = (this.options.constructor == RegExp) ? this.options : this.options.exp;
507 return reg.test(value);
511 * Email regular expression
513 * http://www.regexlib.com/REDetails.aspx?regexp_id=
333
515 email: function(value){
516 var expMail = /^[\w](([_\.\-\+]?[\w]+)*)@([\w]+)(([\.-]?[\w]+)*)\.([A-Za-z]{
2,})$/;
517 return expMail.test(value);
521 * Compare current value with other element
524 compare: function(value){
525 return value == $F(this.options.field);
529 * Apply the rule only when a condition is satisfied
532 conditional: function(value){
537 * test if the value matches the default date pattern
540 date: function(value){
542 var dateInfo = this.element.form._options.dateFormat;
544 var matches = dateInfo.regex.exec(value);
545 if (!matches) return false;
547 var composedDate = new Date(matches[dateInfo.year], (matches[dateInfo.month] -
1), matches[dateInfo.day]);
549 return ((composedDate.getMonth() == (matches[dateInfo.month] -
1)) &&
550 (composedDate.getDate() == matches[dateInfo.day]) &&
551 (composedDate.getFullYear() == matches[dateInfo.year]));
556 * Filter for text inputs
560 trim: function(value){
561 return FormValidator.Filters.trimleft(FormValidator.Filters.trimright(value));
564 trimleft: function(value){
565 return new String(value).replace(/^\s+/, '');
568 trimright: function(value){
569 return new String(value).replace(/\s+$/, '');
573 * Replaces the double spaces for single space
576 singlespace: function(value){
577 return new String(value).replace(/(\s{
2,})/g,' ');
580 lowercase: function(value){
581 return new String(value).toLowerCase();
584 uppercase: function(value){
585 return new String(value).toUpperCase();
588 numbers: function(value){
589 return new String(value).replace(/([^
0-
9])/g, '');
594 var Rule = Class.create();
596 initialize: function(element, ruleName, options, message){
597 this.condition = Prototype.K;
598 this.message = (message || '');
601 options = options || {};
602 this.options = (typeof(options) == 'string') && eval('(' + options + ')') || options;
603 this.element = element;
605 if (typeof(ruleName) == 'string'){
606 this.condition = FormValidator.Conditions[ruleName]; //no bind needed
608 this.condition = ruleName;
612 evaluate: function(){
613 if(this.enabled == false)
616 return this['condition'].call(this, Form.Element.getValue(this.element));
620 this.enabled = false;
630 * The value is required
632 required: function(value){
635 length: function(value){
637 value = (value || '');
638 if (this.options.max)
639 rtn = (value.length <= this.options.max);
641 if (this.options.min)
642 rtn = rtn && (value.length
>= this.options.min);
648 var Filter = Class.create()
650 initialize: function(element, filter, options){
651 this.element = element;
652 this.options = eval('(' + options + ')');
653 this.evaluate = FormValidator.Filters[filter];
657 FormValidator.Error = Class.create();
658 FormValidator.Error.prototype = {
659 initialize: function(element, message){
660 this.element = element;
661 this.message = message;
664 inspect: function() {
665 return '#
<FormValidator.Error:element=' + this.element + ',message=' + this.message + '
>';
669 Object.extend(FormValidator,{Element: {
673 init: function(element){
674 element._rules = _definedConditions.map(function(cond){
675 if (condOptions = element.getAttribute(FormValidator.NSprefix + ':' + cond)){
676 var msg = (element.getAttribute(FormValidator.NSprefix + ':' + cond + '_message')
677 || element.getAttribute(FormValidator.NSprefix + ':' + 'message'));
678 return new Rule(element, cond, condOptions, msg);
682 element._filters = _definedFilters.map(function(filter){
683 if (filterValue = element.getAttribute(FormValidator.NSprefix + ':filter_' + filter)){
684 return new Filter(element, filter, filterValue);
689 if (element.form._options.inline){
690 Event.observe(element, 'change', function(){
691 element.form['_displayFunction'](FormValidator.Element.validate(this));
697 if (element.form._options.inlineFilters){
698 Event.observe(element, 'change', function(){
699 FormValidator.Element.applyFilters(element);
704 addRule: function(element, rule, inline){
705 element._rules.push(rule);
708 addFilter: function(element, filter, inline){
709 element._filters.push(filter);
713 * Returns true if the element has any attribute with the namespace
716 hasRules: function(element){
717 return (element._rules || false);
724 getRules: function(element){
725 return (element._rules || []);
728 getFilters: function(element){
729 return (element._filters || []);
732 isText: function(element){
733 if(element.tagName == null)
736 return ((element.tagName.toLowerCase() == 'input' &&
737 (element.type.toLowerCase() in set('text','hidden','password'))) ||
738 (element.tagName.toLowerCase() == 'textarea'));
742 * Filter can only be applied on textboxes, passwords and textarea
744 applyFilters: function(element){
745 if (FormValidator.Element.isText(element)){
746 FormValidator.Element.getFilters(element).each(function(filter){
747 element.value = filter.evaluate(element.value)
753 * Returns the error objects produced during the validation
756 validate: function(element){
757 FormValidator.Element.applyFilters(element);
758 return FormValidator.Element.getRules(element).map(function(rule){
759 if (!rule.evaluate())
760 return new FormValidator.Error(element, rule.message);
766 Initialize FormValidator after the page has loaded
768 Event.observe(window,'load',FormValidator.init);
769 /*--------------------------------------------------------------------------*/