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=
"fValidateConfig" xml:
space=
"preserve">
65 /* Globals. Modify these to suit your setup
66 ------------------------------------------- */
68 // Attribute used for fValidate Validator codes
69 this.code = 'validators';
71 // Attribute used for custom error messages (override built-in error messages)
74 // Attribute used for pattern with custom validator type
75 this.pattern = 'pattern';
77 // Change this to the classname you want for the error highlighting
78 this.errorClass = 'errHilite';
80 // If you wish fValidate to use only single classNames for errors
81 this.useSingleClassNames = false; // or true
83 // This is the even that triggers the clearing of the errorClass hilighting
84 this.clearEvent = 'change'; // 'change' | 'blur' | null
86 // For browsers that don't support attachEvent or addEventListere - override existing events for error reverting?
87 this.eventOverride = false;
89 // If the bConfirm flag is set to true, the users will be prompted with CONFIRM box with this message
90 // See your language file for this value
91 this.confirmMsg = fvalidate.i18n.config.confirmMsg;
93 // If user cancels CONFIRM, then this message will be alerted. If you don't want this alert to show, then
94 // empty the variable ( this.confirmAbortMsg = ''; )
95 // See your langauge file for this value
96 this.confirmAbortMsg = fvalidate.i18n.config.confirmAbortMsg;
98 // Enter the name/id of your form's submit button here. Can be a string or array of strings
99 this.submitButton = ['Submit','Submit2'];
101 // Enter the name/id of your form's reset button here
102 this.resetButton = 'Reset';
104 // Ender the name or id of the SELECT object here. Make sure you pay attention to the values (CC Types)
105 // used in the case statement for the function validateCC()
106 this.ccType = 'Credit_Card_Type';
108 // NOTE: The config value below exists for backwards compatibility with fValidate
3.55b. If you have a newer
109 // version, use the above this.ccType instead.
110 // Enter the DOM name of the SELECT object here. Make sure you pay attention to the values (CC Types)
111 // used in the case statement for the function validateCC()
112 this.ccTypeObj = 'form1.Credit_Card_Type';
114 // Element where box errors will appear
115 this.boxError = 'errors';
117 // Added by Ivan to allow for a heading in the box error mode
118 this.boxErrorHeadingClass = 'errorsHeading';
120 // Prefix given to all error paragraphs in box error mode
121 this.boxErrorPrefix = 'fv_error_';
123 this.displayName= 'displayName';
126 // Added by Ivan to designate a label to be an error label
127 this.errorSelectorCssClass = 'error';
131 <data name=
"fValidateCore" xml:
space=
"preserve">
134 /***************************************************************************************************
136 *-- Form validation script by Peter Bailey, Copyright (c)
2001-
2003
138 * Updated on Feb
07,
2004
139 * www.peterbailey.net
142 * IF YOU USE THIS SCRIPT, GIVE ME CREDIT PLEASE =)
144 * Visit http://www.peterbailey.net/fValidate/ for more info
146 * Feel free to contact me with any questions, comments, problems, or suggestions
148 * Note: This document most easily read with tab spacing set to
4
150 *******************************************************************************************************/
152 /* Create static fvalidate object
153 ------------------------------------------- */
154 if ( typeof fvalidate == 'undefined' )
156 var fvalidate = new Object();
159 /* Generic event handling
160 ------------------------------------------- */
161 fvalidate.addEvent = function( obj, evt, fn, useCapture )
163 if ( typeof obj.attachEvent != 'undefined' )
165 obj.attachEvent(
"on" + evt, fn );
167 else if ( typeof obj.attachEventListener != 'undefined' )
169 obj.addEventListener( evt, fn, Boolean( useCapture ) );
172 fvalidate.addEvents = function( obj, evts, fn, useCapture )
175 while( evt = evts[i++] )
177 this.addEvent( obj, evt, fn, Boolean( useCapture ) );
181 /* Main validation routine
182 ------------------------------------------- */
183 function validateForm( f, bConfirm, bDisable, bDisableR, groupError, errorMode )
186 bConfirm = Boolean( bConfirm );
187 bDisable = Boolean( bDisable );
188 bDisableR = Boolean( bDisableR );
189 groupError = Boolean( groupError );
190 errorMode = ( typeof errorMode != 'undefined' ) ? parseInt( errorMode,
10 ) :
0;
192 // Init vars and fValidate object
193 var params, fvCode, type;
194 if ( typeof f.fv == 'undefined' )
196 f.fv = new fValidate( f, errorMode, groupError );
199 f.fv.errorMode = errorMode;
202 // Loop through all form elements
203 var elem, i =
0, attr = f.fv.config.code;
204 while ( elem = f.elements[i++] )
207 if ( elem.nodeName ==
"FIELDSET" ) continue;
209 // Does element have validator attribute? (short-circuit check)
210 fvCode = ( elem[attr] ) ? elem[attr] : elem.getAttribute( attr );
211 if ( !( typeof fvCode == 'undefined' || fvCode == null || fvCode ==
"" ) )
213 // Set params, validation type, and validation state
214 params = fvCode.split(
"|" );
216 elem.validated = true;
218 // Valid validator type?
219 if ( typeof f.fv[type] == 'undefined' )
221 f.fv.devError( [type, elem.name], 'notFound' );
225 // Check for modifiers
226 switch( params.last() )
228 case 'bok' : // bok requested
229 params = params.slicex(
1,
1 );
232 case 'if' : // Conditional validation requested
233 params = params.slicex(
1,
1 );
236 case 'then' : // Conditional validation requested
237 params = params.slicex(
1,
1 );
240 default : // No modifiers
241 params = params.slicex(
1,
0 );
245 // Is element an array?
246 if ( /radio|checkbox/.test( elem.type ) )
248 // Set group property
249 elem.group = f.elements[elem.name];
252 // Add events if not already added
253 if ( typeof elem.fName == 'undefined' )
255 // If element is an array
256 if ( typeof elem.group != 'undefined' )
258 for ( var j =
0; j < elem.group.length; j++ )
260 // Apply event-function to each child
261 if ( f.fv.config.clearEvent != null )
263 // fvalidate.addEvent( elem.group.item( j ), fv.config.clearEvent, fv.revertError, false );
264 addEvent( elem.group.item( j ), f.fv.config.clearEvent, f.fv, 'revertError', false );
270 // Apply event-function to element
271 // fvalidate.addEvent( elem, fv.config.clearEvent, fv.revertError, false );
272 addEvent( elem, f.fv.config.clearEvent, f.fv, 'revertError', false );
276 // Set formatted name, current element
277 if ( elem.attributes[f.fv.config.displayName] != null)
279 elem.fName = elem.attributes[f.fv.config.displayName].value.format();
283 elem.fName = elem.name.format();
289 // Create function to call the proper validator method of the fValidate class
290 var func = new Function(
"obj",
"method",
"obj[method]( " + params.toArgString() +
" );" );
293 // If element test failed AND group error is off, return false
294 if ( elem.validated == false && groupError == false ) return false;
296 // Clear error if field okay
297 if ( elem.validated == true ) f.fv.revertError();
299 } // end of element loop
301 // If group error, show it
302 if ( groupError ) f.fv.showGroupError();
304 // Return false if errors found
305 if ( f.fv.errors.length
> 0 ) return false;
307 // Show pre-submission confirmation
308 if ( bConfirm && !confirm( f.fv.config.confirmMsg ) )
310 if ( f.fv.config.confirmAbortMsg != '' ) alert( f.fv.config.confirmAbortMsg );
314 // Disable reset and/or submit buttons if requested
317 if ( typeof f.fv.config.submitButton == 'object' )
320 while( sb = f.fv.config.submitButton[j++] )
322 if ( f.fv.elementExists( sb ) )
324 f.elements[sb].disabled = true;
328 else if ( f.fv.elementExists( f.fv.config.submitButton ) )
330 f.elements[f.fv.config.submitButton].disabled = true;
333 if ( bDisableR && f.fv.elementExists( f.fv.config.resetButton ) )
335 f.elements[f.fv.config.resetButton].disabled = true;
338 // Successful Validation. Submit form
341 function addEvent( elem, evt, obj, method, capture )
344 if ( typeof elem.attachEvent != 'undefined' )
346 elem.attachEvent(
"on" + evt, function() { obj[method]( self ) } );
348 else if ( typeof elem.addEventListener != 'undefined' )
350 elem.addEventListener( evt, function() { obj[method]( self ) }, capture );
352 else if ( f.fv.config.eventOverride )
354 eleme['on' + evt] = function() { obj[method]( self ) };
360 ------------------------------------------- */
361 function fValidate( f, errorMode, groupError )
365 this.errorMode = errorMode;
366 this.groupError = groupError;
367 this.errors = new Array();
368 this.validated = true;
369 this.config = new fValConfig();
370 this.i18n = fvalidate.i18n;
371 var selectorClass = this.config.errorSelectorCssClass;
372 // Add reset action to clear visual error cues
373 f.onreset = function()
376 while ( elem = this.elements[i++] )
378 self.revertError( elem );
382 addLabelProperties();
384 // Parses form and adds label properties to elements that have one specified
385 function addLabelProperties()
387 // Collect all label elements in form, init vars
388 if ( typeof f.getElementsByTagName == 'undefined' ) return;
389 var labels = f.getElementsByTagName(
"label" );
390 var label, i = j =
0;
392 // Loop through labels retrieved
393 while ( label = labels[i++] )
396 if ( typeof label.htmlFor == 'undefined' ) return;
398 // Skip the current element if the label is not for anything
399 if ( label.htmlFor == '') break;
402 elem = f.elements[label.htmlFor];
403 if ( typeof elem == 'undefined' )
404 { // No element found for label
405 self.devError( [label.htmlFor], 'noLabel' );
407 else if ( typeof elem.label != 'undefined' )
408 { // label property already added
411 else if ( typeof elem.length != 'undefined' && elem.length
> 1 && elem.nodeName != 'SELECT' )
412 { // For arrayed elements
413 for ( j =
0; j < elem.length; j++ )
415 elem.item( j ).label = label;
419 if(label.className.indexOf(selectorClass)
> -
1)
426 /* Reset for another validation
427 ------------------------------------------- */
428 fValidate.prototype._reset = function()
430 this.errors = new Array();
431 this.showErrors = new Array();
434 /* Checks if element exists in form
435 ------------------------------------------- */
436 fValidate.prototype.elementExists = function( elemName )
438 return Boolean( typeof this.form.elements[elemName] != 'undefined' );
441 /* Receives error message and determines action
442 ------------------------------------------- */
443 fValidate.prototype.throwError = function( args, which )
445 var elem = this.elem;
448 if ( typeof elem.name == 'undefined' )
453 // Bok requested AND element blank OR conditional validation?
454 if ( elem.bok && this.isBlank() )
456 elem.validated = true;
460 // Part of a conditional validation?
466 // Set failsafe to false
467 elem.validated = false;
469 // Create error message
470 which = this.setArg( which,
0 );
471 args = this.setArg( args, [] );
472 emsgElem = ( typeof this.elem.getAttribute ==
"undefined" ) ?
475 if ( emsgElem.getAttribute( this.config.emsg ) )
477 var error = emsgElem.getAttribute( this.config.emsg );
479 var error = this.translateMessage( args, this.i18n.errors[this.type][which] );
482 if ( this.groupError )
484 // Push error onto stack
485 this.errors.push( {'elem':elem, 'msg': error} );
489 // Process error message
490 this.showError( error, false, emsgElem );
492 var focusElem = ( typeof elem.fields != 'undefined' )?
496 // Focus and select elements, if possible
497 this.selectFocus( focusElem );
502 /* Shows error message to user
503 ------------------------------------------- */
504 fValidate.prototype.showError = function( emsg, last, elem )
508 elem = this.setArg( elem, this.elem ),
509 isHidden = Boolean( elem.type == 'hidden' ),
510 label = ( isHidden ) ? null : elem.label || null,
511 emsg = ( elem.getAttribute( this.config.emsg ) ) ? elem.getAttribute( this.config.emsg ).replace( /\\n/g,
"\n" ) : emsg,
512 errorClass = this.config.errorClass,
513 singleCSS = this.config.useSingleClassNames,
514 selectorClass = this.config.errorSelectorCssClass;
516 if ( typeof this.showErrors == 'undefined' ) this.showErrors = new Array();
518 // Determine which error modes to use
519 switch( this.errorMode )
520 { // This represents all possible combinations
521 case
0 : alertError(); break;
522 case
1 : inputError(); break;
523 case
2 : labelError(); break;
524 case
3 : appendError(); break;
525 case
4 : boxError(); break;
526 case
5 : inputError(); labelError(); break;
527 case
6 : inputError(); appendError(); break;
528 case
7 : inputError(); boxError(); break;
529 case
8 : inputError(); alertError(); break;
530 case
9 : labelError(); appendError(); break;
531 case
10 : labelError(); boxError(); break;
532 case
11 : labelError(); alertError(); break;
533 case
12 : appendError(); boxError(); break;
534 case
13 : appendError(); alertError(); break;
535 case
14 : boxError(); alertError(); break;
536 case
15 : inputError(); labelError(); appendError(); break;
537 case
16 : inputError(); labelError(); boxError(); break;
538 case
17 : inputError(); labelError(); alertError(); break;
539 case
18 : inputError(); appendError(); boxError(); break;
540 case
19 : inputError(); appendError(); alertError(); break;
541 case
20 : inputError(); boxError(); alertError(); break;
542 case
21 : labelError(); appendError(); boxError(); break;
543 case
22 : labelError(); appendError(); alertError(); break;
544 case
23 : appendError(); boxError(); alertError(); break;
545 case
24 : inputError(); labelError(); appendError(); boxError(); break;
546 case
25 : inputError(); labelError(); appendError(); alertError(); break;
547 case
26 : inputError(); appendError(); boxError(); alertError(); break;
548 case
27 : labelError(); appendError(); boxError(); alertError(); break;
549 case
28 : inputError(); labelError(); appendError(); boxError(); alertError(); break;
551 // Regular alert error
552 function alertError()
554 if ( self.groupError ) self.showErrors.push( emsg );
556 if ( last ) alert( self.i18n.groupAlert + self.showErrors.join(
"\n\n- " ) );
558 // Applies class to form element
559 function inputError()
561 if ( ( typeof elem.length != 'undefined' && elem.length
> 1 && elem.nodeName != 'SELECT' ) || isHidden )
564 while( subelem = ( isHidden ) ? elem.fields[i++] : elem.item( i++ ) )
566 if ( subelem.className != '' && singleCSS )
568 subelem.revertClass = subelem.className;
569 subelem.className = errorClass;
571 self.addCSSClass( subelem, errorClass );
579 elem.revertClass = elem.className;
580 elem.className = errorClass;
582 self.addCSSClass( elem, errorClass );
586 // Applies class to element's label
587 function labelError()
589 if ( label == null ) return;
590 if ( self.config.useSingleClassNames )
592 label.className = errorClass;
594 self.addCSSClass( label, errorClass );
598 // Appends error message to element's label
599 function appendError()
601 if ( label == null || label.className.indexOf(selectorClass) == -
1 ) return;
602 if ( typeof label.original == 'undefined' )
603 label.original = label.innerHTML;
604 label.innerHTML = label.original + emsg.toHTML();
606 // Appends Error message to pre-defined element
609 if ( typeof self.boxError == 'undefined' ) self.boxError = document.getElementById( self.config.boxError );
610 if ( self.boxError == null )
612 self.devError( [self.config.boxError], 'noBox' );
615 if ( typeof self.elem.name == 'undefined' || self.elem.name ==
"" )
617 self.devError( [self.elem[self.config.code]], 'missingName' );
620 var errorId = self.config.boxErrorPrefix + self.elem.name,
622 if ( errorElem = document.getElementById( errorId ) ) // short-circuit
624 errorElem.firstChild.innerHTML = emsg.toHTML();
628 errorElem = document.createHTMLElement( 'li', { id: errorId, 'innerHTML': emsg.toHTML(), title: self.i18n.boxToolTip } );
629 self.boxError.appendChild( errorElem );
630 errorElem.onclick = function()
632 var elem = self.form.elements[this.id.replace( self.config.boxErrorPrefix,
"" )];
633 if ( typeof elem.fields != 'undefined' ) elem = elem.fields[
0];
634 if ( typeof elem.select != 'undefined' ) elem.select();
635 if ( typeof elem.focus != 'undefined' ) elem.focus();
638 self.boxError.style.display =
"block";
642 /* Handles element className manipulation
643 ------------------------------------------- */
644 fValidate.prototype.removeCSSClass = function( elem, className )
646 elem.className = elem.className.replace( className,
"" ).trim();
648 fValidate.prototype.addCSSClass = function( elem, className )
650 this.removeCSSClass( elem, className );
651 elem.className = ( elem.className +
" " + className ).trim();
654 /* Processes errors in stack for group error mode
655 ------------------------------------------- */
656 fValidate.prototype.showGroupError = function()
658 for ( var error, firstElem, i =
0; ( error = this.errors[i] ); i++ )
660 if ( i ==
0 ) firstElem = error.elem;
661 this.elem = error.elem;
662 this.showError( error.msg, Boolean( i == ( this.errors.length -
1 ) ) );
665 var focusElem = ( typeof firstElem.fields != 'undefined' )?
668 this.selectFocus( focusElem );
672 /* Reverts any visible error notification upon event
673 ------------------------------------------- */
674 fValidate.prototype.revertError = function( elem )
676 elem = this.setArg( elem, this.elem );
677 var isHidden = Boolean( elem.type == 'hidden' ),
678 errorClass = this.config.errorClass,
682 headingClass = this.config.boxErrorHeadingClass;
684 if ( ( typeof elem.length != 'undefined' && elem.length
> 1 && elem.nodeName != 'SELECT' ) || isHidden )
686 if ( isHidden && typeof elem.fields != 'undefined' )
688 while( subelem = ( isHidden ) ? elem.fields[i++] : elem.item( i++ ) )
690 if ( typeof subelem.revertClass != 'undefined' )
692 subelem.className = subelem.revertClass;
697 if ( this.config.useSingleClassNames )
699 if ( typeof subElement.revertClass != 'undefined' )
701 elem.className = elem.revertClass;
704 this.removeCSSClass( elem, errorClass );
707 if ( typeof elem.label != 'undefined' )
709 if ( this.config.useSingleClassNames )
711 elem.label.className = '';
713 this.removeCSSClass( elem.label, errorClass );
715 elem.label.innerHTML = ( elem.label.original || elem.label.innerHTML );
717 if ( typeof this.boxError != 'undefined' )
719 if ( typeof this.boxError.normalize != 'undefined' ) this.boxError.normalize();
720 if ( errorElem = document.getElementById( this.config.boxErrorPrefix + elem.name ) )
722 this.boxError.removeChild( errorElem );
724 // Added by Ivan allow for a heading node to be in the error box.
726 if(this.boxError.tagName.toUpperCase() == 'UL'){
727 for(var i=
0;i
<this.boxError.childNodes.length;i++){
729 var node = this.boxError.childNodes[i];
730 if(node.tagName && node.tagName == 'LI' && node.className != headingClass) nodeCount++;
732 if ( nodeCount ==
0 ) this.boxError.style.display = 'none';
737 /* Focus and select elements, if possible
738 ------------------------------------------- */
739 fValidate.prototype.selectFocus = function( elem )
741 if ( typeof elem.select != 'undefined' ) elem.select();
742 if ( typeof elem.focus != 'undefined' ) elem.focus();
745 /* Developer assistance method - shows error if validator/element-type mismatch
746 ------------------------------------------- */
747 fValidate.prototype.typeMismatch = function()
750 'text': 'text|password|textarea',
754 'sm': 'select-multiple',
755 'select': 'select-one|select-multiple',
762 expected = new Array(),
763 result = key = type = regex =
"";
764 for ( var i =
0; i < arguments.length; i++ )
766 type = pats[arguments[i]];
767 regex = new RegExp( type );
768 result += ( regex.test( this.elem.type ) ) ?
"1" :
"0";
770 expected.push( type );
772 if ( key ^ result ==
0 )
774 this.devError( [this.elem.fName, this.elem.type, expected.join(
"|" ).replace( /\|/g, this.i18n.or )], 'mismatch' );
775 this.elem.validated = false;
781 /* Returns value(s) of reference element passed
782 ------------------------------------------- */
783 fValidate.prototype.getValue = function( elem )
794 case 'select-single':
795 if ( typeof elem.length == 'undefined' )
799 for ( var i =
0; i < elem.length; i++ )
801 choice = ( elem.type == 'radio' ) ?
"checked" :
"selected";
802 if ( elem[i][choice] )
804 return elem[i].value;
808 case 'select-multiple' :
810 if ( typeof elem.length == 'undefined' )
814 var returnValues = new Array();
815 for ( var i =
0; i < elem.length; i++ )
817 choice = ( elem.type == 'checkbox' ) ?
"checked" :
"selected";
818 if ( elem[i][choice] )
820 returnValues.push( elem[i].value );
825 default: return null;
829 /* Generic argument setting method
830 ------------------------------------------- */
831 fValidate.prototype.setArg = function( arg, def )
833 return ( typeof arg == 'undefined' || arg == '' || arg == null ) ? def : arg;
836 /* Blank checker. Optional string argument for evaluating element other than current
837 ------------------------------------------- */
838 fValidate.prototype.isBlank = function( el )
840 var elem = this.form.elements[el] || this.elem;
841 return Boolean( /^\s*$/.test( elem.value ) );
844 /* Translates messages using language file
845 ------------------------------------------- */
846 fValidate.prototype.translateMessage = function( args, format )
849 for ( var i =
0; i < format.length; i++ )
851 msg += ( typeof format[i] == 'number' ) ? args[format[i]] : format[i];
856 /* Throws developer errors
857 ------------------------------------------- */
858 fValidate.prototype.devError = function( args, which )
860 if ( typeof args == 'string' )
865 which = this.setArg( which, this.type );
866 var format = this.i18n.devErrors[which];
868 this.i18n.devErrors.lines[
0],
869 '----------------------------------------------------------------------------------------------',
870 this.translateMessage( args, format ),
871 '----------------------------------------------------------------------------------------------',
872 this.i18n.devErrors.lines[
1]
874 alert( a.join(
"\n" ) );
877 /* Throws specific developer error
878 ------------------------------------------- */
879 fValidate.prototype.paramError = function( param, elemName )
881 elemName = this.setArg( elemName, this.elem.name );
882 this.devError( [param, this.type, elemName], 'paramError' );
884 /* Non-fValidate methods *****************************************/
886 /* For easy creation of DOM nodes
887 ------------------------------------------- */
888 document.createHTMLElement = function( elemName, attribs )
890 if ( typeof document.createElement == 'undefined' ) return;
891 var elem = document.createElement( elemName );
892 if ( typeof attribs != 'undefined' )
894 for ( var i in attribs )
898 case ( i == 'text' ) : elem.appendChild( document.createTextNode( attribs[i] ) ); break;
899 case ( i == 'class' ) : elem.className = attribs[i]; break;
900 default : elem.setAttribute( i, '' ); elem[i] = attribs[i];
907 /* Trims b items from the beginning of the array, e items from the end
908 ------------------------------------------- */
909 Array.prototype.slicex = function( b, e )
913 for ( var i = b; i < this.length - e; i++ )
915 a[count++] = this[i];
920 /* Returns array as argument-compatible string
921 ------------------------------------------- */
922 Array.prototype.toArgString = function()
925 for ( var i =
0; i < this.length; i++ )
927 a.push(
"'" + this[i] +
"'" );
932 /* Prototype push if missing
933 ------------------------------------------- */
934 if ( typeof Array.prototype.push == 'undefined' )
936 Array.prototype.push = function()
938 for ( var i =
0; i < arguments.length; i++ )
940 this[this.length] = arguments[i];
945 /* Returns last item of the array
946 ------------------------------------------- */
947 Array.prototype.last = function()
949 return this[this.length-
1];
952 /* Removes the follow charaters _[] from an elements name for human-reading
953 ------------------------------------------- */
954 String.prototype.format = function()
956 return this.replace( /\_/g,
" ").replace( /\[|\]/g,
"" );
959 /* Replaces newline characters with XHTML BR tags
960 ------------------------------------------- */
961 String.prototype.toHTML = function()
963 return this.replace( /\n/g,
"<br />" ).replace( /\t/g,
" " );
966 /* Trims leading and trailing whitespace from string
967 ------------------------------------------- */
968 String.prototype.trim = function()
970 return this.replace( /^\s+|\s+$/,
"" );
973 /* Escapes necessary charactes for string-generated regular expressions
974 ------------------------------------------- */
975 String.prototype.toPattern = function()
977 return this.replace( /([\.\*\+\{\}\(\)\<\
>\^\$\\])/g,
"\\$1" );
983 <data name=
"fValidateValidators" xml:
space=
"preserve">
985 /*< blank basic *******************************************************************/
986 fValidate.prototype.blank = function()
988 if ( this.typeMismatch( 'text' ) ) return;
989 if ( this.isBlank() )
991 this.throwError( [this.elem.fName] );
995 /*< number numbers *******************************************************************/
996 fValidate.prototype.number = function( type, lb, ub )
998 if ( this.typeMismatch( 'text' ) ) return;
999 var num = ( type ==
0 ) ? parseInt( this.elem.value,
10 ) : parseFloat( this.elem.value );
1000 lb = this.setArg( lb,
0 );
1001 ub = this.setArg( ub, Number.infinity );
1004 this.devError( [lb, ub, this.elem.name] );
1007 var fail = Boolean( isNaN( num ) || num != this.elem.value );
1012 case ( lb != false && ub != false ) : fail = !Boolean( lb <= num && num <= ub ); break;
1013 case ( lb != false ) : fail = Boolean( num < lb ); break;
1014 case ( ub != false ) : fail = Boolean( num
> ub ); break;
1019 this.throwError( [this.elem.fName] );
1022 this.elemPass = true;
1025 /*< numeric numbers *******************************************************************/
1026 fValidate.prototype.numeric = function( len )
1028 if ( this.typeMismatch( 'text' ) ) return;
1029 len = this.setArg( len, '*' );
1030 var regex = new RegExp( ( len == '*' ) ?
"^\\d+$" :
"^\\d{" + parseInt( len,
10 ) +
"}\\d*$" );
1031 if ( !regex.test( this.elem.value ) )
1035 this.throwError( [this.elem.fName] );
1037 this.throwError( [len, this.elem.fName],
1 );
1042 /*< length basic *******************************************************************/
1043 fValidate.prototype.length = function( len, maxLen )
1045 if ( this.typeMismatch( 'text' ) ) return;
1046 var vlen = this.elem.value.length;
1047 len = Math.abs( len );
1048 maxLen = Math.abs( this.setArg( maxLen, Number.infinity ) );
1051 this.devError( [len, maxLen, this.elem.name] );
1054 if ( len
> parseInt( vlen,
10 ) )
1056 this.throwError( [this.elem.fName, len] );
1058 if ( vlen
> maxLen )
1060 this.throwError( [this.elem.fName, maxLen, vlen],
1 );
1064 /*< alnum extended *******************************************************************/
1065 fValidate.prototype.alnum = function( minLen, tCase, numbers, spaces, puncs )
1067 if ( this.typeMismatch( 'text' ) ) return;
1069 tCase = this.setArg( tCase,
"a" );
1071 //alert( [minLen,tCase,numbers,spaces,puncs] );
1073 numbers = ( numbers ==
"true" || numbers ==
"1" );
1074 spaces = ( spaces ==
"true" || spaces ==
"1" );
1076 //alert( [minLen,tCase,numbers,spaces,puncs] );
1079 arrE = ['None','Any','No','No','Any'];
1081 if ( minLen != '*' )
1083 minLen = parseInt( minLen,
10 );
1089 switch( tCase.toUpperCase() )
1100 okChars += 'A-Z][a-z';
1101 arrE[
1] = 'Intial capital';
1105 okChars += 'a-zA-Z';
1109 if ( numbers == true )
1114 if ( spaces == true )
1119 if ( puncs ==
"any" )
1123 else if ( puncs ==
"none" )
1129 puncs = puncs.replace( /pipe/g,
"|" );
1131 arrE[
4] = puncs; //.toPattern().replace( /\\/g,
"" );
1133 var length = ( minLen !=
"*" )?
1134 "{" + minLen +
",}":
1136 var regex = ( puncs ==
"any" ) ?
1137 new RegExp(
"^([" + okChars +
"]|[^a-zA-Z0-9\\s])" + length +
"$" ):
1138 new RegExp(
"^[" + okChars +
"]" + length +
"$" );
1140 if ( !regex.test( this.elem.value ) )
1142 this.throwError( [this.elem.value, this.elem.fName, arrE[
0], arrE[
1], arrE[
2], arrE[
3], arrE[
4]] );
1146 /*< equalto logical *******************************************************************/
1147 fValidate.prototype.equalto = function( oName )
1149 if ( this.typeMismatch( 'text' ) ) return;
1150 if ( typeof oName == 'undefined' )
1152 this.paramError( 'oName' );
1154 var otherElem = this.form.elements[oName];
1155 if ( this.elem.value != otherElem.value )
1157 this.throwError( [this.elem.fName,otherElem.fName] );
1161 /*< ssn extended *******************************************************************/
1162 fValidate.prototype.ssn = function()
1164 if ( this.typeMismatch( 'text' ) ) return;
1165 if ( !( /^\d{
3}\-\d{
2}\-\d{
4}$/.test( this.elem.value ) ) )
1169 /*< select controls *******************************************************************/
1170 fValidate.prototype.select = function()
1172 if ( this.typeMismatch( 's1' ) ) return;
1173 if ( this.elem.selectedIndex ==
0 )
1175 this.throwError( [this.elem.fName] );
1179 /*< selectm controls *******************************************************************/
1180 fValidate.prototype.selectm = function( minS, maxS )
1182 if ( this.typeMismatch( 'sm' ) ) return;
1183 if ( typeof minS == 'undefined' )
1185 this.paramError( 'minS' );
1187 if ( maxS ==
999 || maxS == '*' || typeof maxS == 'undefined' || maxS
> this.elem.length ) maxS = this.elem.length;
1190 for ( var opt, i =
0; ( opt = this.elem.options[i] ); i++ )
1192 if ( opt.selected ) count++;
1195 if ( count < minS || count
> maxS )
1197 this.throwError( [minS, maxS, this.elem.fName, count] );
1201 /*< selecti controls *******************************************************************/
1202 fValidate.prototype.selecti = function( indexes )
1205 if ( this.typeMismatch( 's1' ) ) return;
1206 if ( typeof indexes == 'undefined' )
1208 this.paramError( 'indexes' );
1211 indexes = indexes.split(
"," );
1212 var selectOK = true;
1214 for ( var i =
0; i < indexes.length; i++ )
1216 if ( this.elem.options[indexes[i]].selected )
1224 this.throwError( [this.elem.fName] );
1228 /*< cazip international *******************************************************************/
1229 fValidate.prototype.cazip = function()
1231 var elem = this.elem;
1232 if ( this.typeMismatch( 'text' ) ) return;
1233 elem.value = elem.value.toUpperCase();
1234 if ( !( /^[A-Z][
0-
9][A-Z] [
0-
9][A-Z][
0-
9]$/.test( elem.value ) ) )
1239 fValidate.prototype.capost = fValidate.prototype.cazip;
1241 /*< ukpost international *******************************************************************/
1242 fValidate.prototype.ukpost = function()
1244 var elem = this.elem;
1245 if ( this.typeMismatch( 'text' ) ) return;
1246 elem.value = elem.value.toUpperCase();
1247 if ( !( /^[A-Z]{
1,
2}\d[\dA-Z] ?\d[A-Z]{
2}$/.test( elem.value ) ) )
1253 /*< germanpost international *******************************************************************/
1254 fValidate.prototype.germanpost = function()
1256 var elem = this.elem;
1257 if ( this.typeMismatch( 'text' ) ) return;
1258 elem.value = elem.value.toUpperCase();
1259 if ( !( /^(?:CH\-)\d{
4}$/.test( elem.value ) ) )
1265 /*< swisspost international *******************************************************************/
1266 fValidate.prototype.swisspost = function()
1268 var elem = this.elem;
1269 if ( this.typeMismatch( 'text' ) ) return;
1270 elem.value = elem.value.toUpperCase();
1271 if ( !( /^(?:D\-)\d{
5}$/.test( this.elem.value ) ) )
1277 /*< email web *******************************************************************/
1278 fValidate.prototype.email = function( level )
1280 if ( this.typeMismatch( 'text' ) ) return;
1281 if ( typeof level == 'undefined' ) level =
0;
1282 var emailPatterns = [
1284 /^\w.+@\w.+\.[a-z]+$/i,
1285 /^\w[-_a-z~.]+@\w[-_a-z~.]+\.[a-z]{
2}[a-z]*$/i,
1286 /^\w[\w\d]+(\.[\w\d]+)*@\w[\w\d]+(\.[\w\d]+)*\.[a-z]{
2,
7}$/i
1288 if ( ! emailPatterns[level].test( this.elem.value ) )
1294 /*< url web *******************************************************************/
1295 fValidate.prototype.url = function( hosts, hostOptional, allowQS )
1297 if ( this.typeMismatch( 'text' ) ) return;
1299 this.setArg( hosts,
"http" );
1301 var front =
"^(?:(" + hosts.replace( /\,/g,
"|" ) +
")\\:\\/\\/)";
1302 var end = ( Boolean( allowQS ) == true ) ?
"(\\?.*)?$" :
"$";
1304 if ( Boolean( hostOptional ) == true ) front +=
"?";
1305 var regex = new RegExp( front +
"([\\w\\d-]+\\.?)+" + end );
1307 if ( !regex.test( this.elem.value ) )
1309 this.throwError( [this.elem.fName] );
1313 /*< ip web *******************************************************************/
1314 fValidate.prototype.ip = function( portMin, portMax )
1316 if ( this.typeMismatch( 'text' ) ) return;
1317 portMin = this.setArg( portMin,
0 );
1318 portMax = this.setArg( portMax,
99999 );
1319 if ( !( /^\d{
1,
3}(\.\d{
1,
3}){
3}(:\d+)?$/.test( this.elem.value ) ) )
1325 var part, i =
0, parts = this.elem.value.split( /[.:]/ );
1326 while ( part = parts[i++] )
1328 if ( i ==
5 ) // Check port
1330 if ( part < portMin || part
> portMax )
1332 this.throwError( [part, portMin, portMax],
1 );
1335 else if ( part <
0 || part
> 255 )
1343 /*< decimal numbers *******************************************************************/
1344 fValidate.prototype.decimal = function( lval, rval )
1346 if ( this.typeMismatch( 'text' ) ) return;
1347 var regex = '', elem = this.elem;
1348 if ( lval != '*' ) lval = parseInt( lval,
10 );
1349 if ( rval != '*' ) rval = parseInt( rval,
10 );
1352 regex =
"^\\.[0-9]{" + rval +
"}$";
1353 else if ( lval == '*' )
1354 regex =
"^[0-9]*\\.[0-9]{" + rval +
"}$";
1355 else if ( rval == '*' )
1356 regex =
"^[0-9]{" + lval +
"}\\.[0-9]+$";
1358 regex =
"^[0-9]{" + lval +
"}\\.[0-9]{" + rval +
"}$";
1360 regex = new RegExp( regex );
1362 if ( !regex.test( elem.value ) )
1364 this.throwError( [elem.value,elem.fName] );
1368 /*< decimalr numbers *******************************************************************/
1369 fValidate.prototype.decimalr = function( lmin, lmax, rmin, rmax )
1371 if ( this.typeMismatch( 'text' ) ) return;
1372 lmin = ( lmin == '*' )?
0 : parseInt( lmin,
10 );
1373 lmax = ( lmax == '*' )? '': parseInt( lmax,
10 );
1374 rmin = ( rmin == '*' )?
0 : parseInt( rmin,
10 );
1375 rmax = ( rmax == '*' )? '': parseInt( rmax,
10 );
1376 var decReg =
"^[0-9]{"+lmin+
","+lmax+
"}\\.[0-9]{"+rmin+
","+rmax+
"}$"
1377 var regex = new RegExp(decReg);
1378 if ( !regex.test( this.elem.value ) )
1380 this.throwError( [this.elem.fName] );
1385 /*< zip extended *******************************************************************/
1386 fValidate.prototype.zip = function( sep )
1388 if ( this.typeMismatch( 'text' ) ) return;
1389 sep = this.setArg( sep,
"- " );
1390 var regex = new RegExp(
"^[0-9]{5}(|[" + sep.toPattern() +
"][0-9]{4})?$" );
1391 if ( ! regex.test( this.elem.value ) )
1397 /*< phone extended *******************************************************************/
1398 fValidate.prototype.phone = function( format )
1400 if ( this.typeMismatch( 'text' ) ) return;
1401 format = this.setArg( format,
0 );
1403 /^(\(?\d\d\d\)?)?[ -]?\d\d\d[ -]?\d\d\d\d$/, // loose
1404 /^(\(\d\d\d\) )?\d\d\d[ -]\d\d\d\d$/ // strict
1406 if ( !patterns[format].test( this.elem.value ) )
1412 this.throwError( [],
1 );
1417 /*< date datetime *******************************************************************/
1418 fValidate.prototype.date = function( formatStr, delim, code, specDate )
1420 if ( this.typeMismatch( 'text' ) ) return;
1421 if ( typeof formatStr == 'undefined' )
1423 this.paramError( 'formatStr' );
1427 delim = this.setArg( delim,
"/" );
1429 var error = [this.elem.fName, formatStr.replace( /\//g, delim )];
1430 var format = formatStr.split(
"/" );
1431 var compare = this.elem.value.split( delim );
1432 var order = new Object();
1434 for ( var i =
0; i < format.length; i++ )
1436 switch( format[i].charAt(
0 ).toLowerCase() )
1449 var thisDate = new Date( compare[order.years], compare[order.months]-
1, compare[order.days] );
1451 if ( isNaN( thisDate ) || thisDate.getDate() != compare[order.days] || thisDate.getMonth() != compare[order.months]-
1 || thisDate.getFullYear().toString().length != formatStr.match( /y/g ).length )
1453 this.throwError( error );
1457 var compareElem = this.form.elements[specDate];
1458 if ( typeof compareElem != 'undefined' )
1460 specDate = compareElem.validDate || compareElem.value;
1462 var compareDate = ( specDate == 'today' )?
1464 new Date( specDate );
1465 compareDate.setHours(
0);
1466 compareDate.setMinutes(
0);
1467 compareDate.setSeconds(
0);
1468 compareDate.setMilliseconds(
0);
1470 var timeDiff = compareDate.getTime() - thisDate.getTime();
1473 switch ( parseInt( code ) ) {
1474 case
1 : // Before specDate
1475 dateOk = Boolean( timeDiff
> 0 );
1478 case
2 : // Before or on specDate
1479 dateOk = Boolean( ( timeDiff +
86400000 )
> 0 );
1482 case
3 : // After specDate
1483 dateOk = Boolean( timeDiff <
0 );
1486 case
4 : // After or on specDate
1487 dateOk = Boolean( ( timeDiff -
86400000 ) <
0 );
1490 default : dateOk = true;
1494 this.throwError( [specDate], error );
1496 this.elem.validDate = thisDate.toString();
1499 /*< money ecommerce *******************************************************************/
1500 fValidate.prototype.money = function( ds, grp, dml )
1502 if ( this.typeMismatch( 'text' ) ) return;
1504 ds = ( ds == ' ' ) ? false : ds.toPattern();
1505 grp = ( grp == ' ' ) ? false : grp.toPattern();
1506 dml = ( dml == ' ' ) ? false : dml.toPattern();
1508 var moneySyntax, pattern;
1512 case Boolean( ds && grp && dml ): // Dollar sign, grouping, and decimal
1513 pattern =
"^" + ds +
"(?:(?:[0-9]{1,3}" + grp +
")(?:[0-9]{3}" + grp +
")*[0-9]{3}|[0-9]{1,3})(" + dml +
"[0-9]{2})$";
1514 moneySyntax = ds +
"XX" + grp +
"XXX" + dml +
"XX";
1516 case Boolean( ds && grp && !dml ): // Dollar sign and grouping
1517 pattern =
"^" + ds +
"(?:(?:[0-9]{1,3}" + grp +
")(?:[0-9]{3}" + grp +
")*[0-9]{3}|[0-9]{1,3})$";
1518 moneySyntax =
"" + ds +
"XX" + grp +
"XXX";
1520 case Boolean( ds && !grp && dml ): // Dollar sign and decimal
1521 pattern =
"^" + ds +
"[0-9]*(\\.[0-9]{2})$";
1522 moneySyntax =
"" + ds +
"XXXXX" + dml +
"XX";
1524 case Boolean( !ds && grp && dml ): // Grouping and decimal
1525 pattern =
"^(?:(?:[0-9]{1,3}" + grp +
")(?:[0-9]{3}" + grp +
")*[0-9]{3}|[0-9]{1,3})(" + dml +
"[0-9]{2})?$";
1526 moneySyntax =
"XX" + grp +
"XXX" + dml +
"XX";
1528 case Boolean( ds && !grp && !dml ): // Dollar sign only
1529 pattern =
"^" + ds +
"[0-9]*$";
1530 moneySyntax =
"" + ds +
"XXXXX";
1532 case Boolean( !ds && grp && !dml ): // Grouping only
1533 pattern =
"^(?:(?:[0-9]{1,3}" + grp +
")(?:[0-9]{3}" + grp +
")*[0-9]{3}|[0-9]{1,3})$";
1534 moneySyntax =
"XX" + grp +
"XXX";
1536 case Boolean( !ds && !grp && dml ): // Decimal only
1537 pattern =
"^[0-9]*(" + dml +
"[0-9]{2})$";
1538 moneySyntax =
"XXXXX" + dml +
"XX";
1540 case Boolean( !ds && !grp && !dml ): // No params set, all special chars become optional
1541 pattern =
"^.?(?:(?:[0-9]{1,3}.?)(?:[0-9]{3}.?)*[0-9]{3}|[0-9]{1,3})(.[0-9]{2})?$";
1542 moneySyntax =
"[?]XX[?]XXX[?XX]";
1545 var regex = new RegExp( pattern );
1546 if ( !regex.test( this.elem.value ) )
1548 this.throwError( [this.elem.fName, moneySyntax.replace( /\\/g, '' )] );
1552 /*< checkbox controls *******************************************************************/
1553 fValidate.prototype.checkbox = function( minC, maxC )
1555 if ( this.typeMismatch( 'cb' ) ) return;
1556 if ( typeof minC == 'undefined' )
1558 this.paramError( 'minC' );
1561 if ( this.elem == this.form.elements[this.elem.name] && !this.elem.checked )
1563 this.throwError( [this.elem.fName] );
1567 this.elem = this.form.elements[this.elem.name];
1568 var len = this.elem.length;
1571 if ( maxC ==
999 || maxC == '*' || typeof maxC == 'undefined' || maxC
> this.elem.length )
1578 if ( this.elem[i].checked )
1583 if ( count < minC || count
> maxC )
1585 this.throwError( [minC, maxC, this.elem[
0].fName, count] );
1590 /*< radio controls *******************************************************************/
1591 fValidate.prototype.radio = function()
1593 if ( this.typeMismatch( 'rg' ) ) return;
1594 if ( this.elem == this.form.elements[this.elem.name] && !this.elem.checked )
1596 this.throwError( [this.elem.fName] );
1600 this.elem = this.form.elements[this.elem.name];
1602 for ( var i =
0; i < this.elem.length; i++ )
1604 if ( this.elem.item( i ).checked )
1609 this.throwError( [this.elem[
0].fName] );
1613 /*< eitheror logical *******************************************************************/
1614 fValidate.prototype.eitheror = function()
1616 if ( this.typeMismatch( 'hidden' ) ) return;
1617 if ( typeof arguments[
0] == 'undefined' )
1619 this.paramError( 'delim' );
1622 if ( typeof arguments[
1] == 'undefined' )
1624 this.paramError( 'fields' );
1628 fields = new Array(),
1631 args = arguments[
1].split( arguments[
0] );
1633 this.elem.fields = new Array();
1635 while ( arg = args[i++] )
1637 field = this.form.elements[arg];
1638 fields.push( field.fName );
1639 this.elem.fields.push( field );
1641 if ( !this.isBlank( arg ) )
1648 this.throwError( [fields.join(
"\n\t-" )] );
1652 /*< atleast logical *******************************************************************/
1653 fValidate.prototype.atleast = function()
1655 if ( this.typeMismatch( 'hidden' ) ) return;
1656 if ( typeof arguments[
0] == undefined )
1658 this.paramError( 'qty' );
1661 if ( typeof arguments[
1] == undefined )
1663 this.paramError( 'delim' );
1666 if ( typeof arguments[
2] == undefined )
1668 this.paramError( 'fields' );
1672 fields = new Array(),
1675 args = arguments[
2].split( arguments[
1] );
1677 this.elem.fields = new Array();
1679 while ( arg = args[i++] )
1681 field = this.form.elements[arg];
1682 fields.push( field.fName );
1683 this.elem.fields.push( field );
1685 if ( !this.isBlank( arg ) )
1690 if ( nbCount < arguments[
0] )
1692 this.throwError( [arguments[
0], fields.join(
"\n\t-" ), nbCount] );
1696 /*< allornone logical *******************************************************************/
1697 fValidate.prototype.allornone = function()
1699 if ( this.typeMismatch( 'hidden' ) ) return;
1700 if ( typeof arguments[
0] == 'undefined' )
1702 this.paramError( 'delim' );
1705 if ( typeof arguments[
1] == 'undefined' )
1707 this.paramError( 'fields' );
1711 fields = new Array(),
1714 args = arguments[
1].split( arguments[
0] );
1716 this.elem.fields = new Array();
1718 while ( arg = args[i++] )
1720 field = this.form.elements[arg];
1721 fields.push( field.fName );
1722 this.elem.fields.push( field );
1724 if ( !this.isBlank( arg ) )
1729 if ( nbCount
> 0 && nbCount < args.length )
1731 this.throwError( [fields.join(
"\n\t-" ), nbCount] );
1735 /*< comparison logical *******************************************************************/
1736 fValidate.prototype.comparison = function( field1, operator, field2 )
1738 if ( this.typeMismatch( 'hidden' ) ) return;
1739 var elem1 = this.form.elements[field1],
1740 elem2 = this.form.elements[field2],
1741 value1 = this.getValue( elem1 ),
1742 value2 = this.getValue( elem2 );
1743 i18n = this.i18n.comparison;
1755 while( operators[++i][
0] != operator ){ }
1756 this.elem.fields = [elem1, elem2];
1757 if ( ! eval( value1 + operator + value2 ) )
1759 this.throwError( [elem1.fName, operators[i][
1], elem2.fName] );
1763 /*< file controls *******************************************************************/
1764 fValidate.prototype.file = function( extensions, cSens )
1766 if ( this.typeMismatch( 'file' ) ) return;
1767 if ( typeof extensions == 'undefined' )
1769 this.paramError( 'extensions' );
1772 cSens = Boolean( cSens ) ?
"" :
"i";
1773 var regex = new RegExp(
"^.+\\.(" + extensions.replace( /,/g,
"|" ) +
")$", cSens );
1774 if ( ! regex.test( this.elem.value ) )
1776 this.throwError( [extensions.replace( /,/g,
"\n" )] );
1780 /*< custom special *******************************************************************/
1781 fValidate.prototype.custom = function( flags, reverseTest )
1783 if ( this.typeMismatch( 'text' ) ) return;
1784 flags = ( flags ) ? flags.replace( /[^gim]/ig ) :
"";
1785 var regex = new RegExp( this.elem.getAttribute( this.config.pattern ), flags );
1786 if ( !regex.test( this.elem.value ) )
1788 this.throwError( [this.elem.fName] );
1792 /*< cc ecommerce *******************************************************************/
1793 fValidate.prototype.cc = function()
1795 if ( this.typeMismatch( 'text' ) ) return;
1796 var typeElem = this.form.elements[this.config.ccType];
1800 this.devError( 'noCCType' )
1803 var ccType = typeElem.options[typeElem.selectedIndex].value.toUpperCase();
1806 'VISA' : /^
4\d{
12}(\d{
3})?$/,
1807 'MC' : /^
5[
1-
5]\d{
14}$/,
1808 'DISC' : /^
6011\d{
12}$/,
1809 'AMEX' : /^
3[
4|
7]\d{
13}$/,
1810 'DINERS' : /^
3[
0|
6|
8]\d{
12}$/,
1811 'ENROUTE' : /^
2[
014|
149]\d{
11}$/,
1812 'JCB' : /^
3[
088|
096|
112|
158|
337|
528]\d{
12}$/,
1813 'SWITCH' : /^(
49030[
2-
9]|
49033[
5-
9]|
49110[
1-
2]|
4911(
7[
4-
9]|
8[
1-
2])|
4936[
0-
9]{
2}|
564182|
6333[
0-
4][
0-
9]|
6759[
0-
9]{
2})\d{
10}(\d{
2,
3})?$/,
1814 'DELTA' : /^
4(
1373[
3-
7]|
462[
0-
9]{
2}|
5397[
8|
9]|
54313|
5443[
2-
5]|
54742|
567(
2[
5-
9]|
3[
0-
9]|
4[
0-
5])|
658[
3-
7][
0-
9]|
659(
0[
1-
9]|[
1-
4][
0-
9]|
50)|
844[
09|
10]|
909[
6-
7][
0-
9]|
9218[
1|
2]|
98824)\d{
10}$/,
1815 'SOLO' : /^(
6334[
5-
9][
0-
9]|
6767[
0-
9]{
2})\d{
10}(\d{
2,
3})?$/
1817 if ( typeElem.validated == false && this.groupError == true ) return;
1818 if ( typeof types[ccType] == 'undefined' && typeElem.validated == false && this.groupError == false )
1820 this.devError( [ccType] );
1823 this.elem.value = this.elem.value.replace( /[^\d]/g,
"" );
1824 if ( !types[ccType].test( this.elem.value ) || !this.elem.value.luhn() )
1826 this.throwError( [this.elem.fName] );
1830 String.prototype.luhn = function()
1832 var i = this.length;
1833 var checkSum =
"", digit;
1834 while ( digit = this.charAt( --i ) )
1836 checkSum += ( i %
2 ==
0 ) ? digit *
2 : digit;
1838 checkSum = eval( checkSum.split('').join('+') );
1839 return ( checkSum %
10 ==
0 );
1842 /*< ccDate ecommerce *******************************************************************/
1843 fValidate.prototype.ccDate = function( month, year )
1845 if ( this.typeMismatch( 's1' ) ) return;
1846 year = parseInt( this.getValue( this.form.elements[year] ),
10 ) +
2000;
1847 month = parseInt( this.getValue( this.form.elements[month] ),
10 );
1849 var today = new Date();
1850 var expDate = new Date( year, month )
1852 if ( expDate < today )
1854 alert( [
"Card Expired",today,expDate].join(
"\n" ) );