ÿþ/ /   L i v e V a l i d a t i o n   1 . 3   ( s t a n d a l o n e   v e r s i o n )  
 / /   C o p y r i g h t   ( c )   2 0 0 7 - 2 0 0 8   A l e c   H i l l   ( w w w . l i v e v a l i d a t i o n . c o m )  
 / /   L i v e V a l i d a t i o n   i s   l i c e n s e d   u n d e r   t h e   t e r m s   o f   t h e   M I T   L i c e n s e  
  
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   L i v e V a l i d a t i o n   c l a s s   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /  
  
 / * *  
   * 	 v a l i d a t e s   a   f o r m   f i e l d   i n   r e a l - t i m e   b a s e d   o n   v a l i d a t i o n s   y o u   a s s i g n   t o   i t  
   * 	  
   * 	 @ v a r   e l e m e n t   { m i x e d }   -   e i t h e r   a   d o m   e l e m e n t   r e f e r e n c e   o r   t h e   s t r i n g   i d   o f   t h e   e l e m e n t   t o   v a l i d a t e  
   * 	 @ v a r   o p t i o n s O b j   { O b j e c t }   -   g e n e r a l   o p t i o n s ,   s e e   b e l o w   f o r   d e t a i l s  
   *  
   * 	 o p t i o n s O b j   p r o p e r t i e s :  
   * 	 	 	 	 	 	 	 v a l i d M e s s a g e   { S t r i n g }   	 -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   p a s s e s   v a l i d a t i o n  
   * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " T h a n k y o u ! " )  
   * 	 	 	 	 	 	 	 o n V a l i d   { F u n c t i o n }   	 	 -   f u n c t i o n   t o   e x e c u t e   w h e n   f i e l d   p a s s e s   v a l i d a t i o n  
   * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f u n c t i o n ( ) {   t h i s . i n s e r t M e s s a g e ( t h i s . c r e a t e M e s s a g e S p a n ( ) ) ;   t h i s . a d d F i e l d C l a s s ( ) ;   }   ) 	  
   * 	 	 	 	 	 	 	 o n I n v a l i d   { F u n c t i o n }   	 -   f u n c t i o n   t o   e x e c u t e   w h e n   f i e l d   f a i l s   v a l i d a t i o n  
   * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f u n c t i o n ( ) {   t h i s . i n s e r t M e s s a g e ( t h i s . c r e a t e M e s s a g e S p a n ( ) ) ;   t h i s . a d d F i e l d C l a s s ( ) ;   } )  
   * 	 	 	 	 	 	 	 i n s e r t A f t e r W h a t N o d e   { I n t }   	 -   p o s i t i o n   t o   i n s e r t   d e f a u l t   m e s s a g e  
   * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   t h e   f i e l d   t h a t   i s   b e i n g   v a l i d a t e d ) 	  
   *                             o n l y O n B l u r   { B o o l e a n }   -   w h e t h e r   y o u   w a n t   i t   t o   v a l i d a t e   a s   y o u   t y p e   o r   o n l y   o n   b l u r  
   *                                                         ( D E F A U L T :   f a l s e )  
   *                             w a i t   { I n t e g e r }   -   t h e   t i m e   y o u   w a n t   i t   t o   p a u s e   f r o m   t h e   l a s t   k e y s t r o k e   b e f o r e   i t   v a l i d a t e s   ( m s )  
   *                                                         ( D E F A U L T :   0 )  
   *                             o n l y O n S u b m i t   { B o o l e a n }   -   w h e t h e r   s h o u l d   b e   v a l i d a t e d   o n l y   w h e n   t h e   f o r m   i t   b e l o n g s   t o   i s   s u b m i t t e d  
   *                                                         ( D E F A U L T :   f a l s e ) 	 	 	 	 	 	  
   * /  
 v a r   L i v e V a l i d a t i o n   =   f u n c t i o n ( e l e m e n t ,   o p t i o n s O b j ) {  
     	 t h i s . i n i t i a l i z e ( e l e m e n t ,   o p t i o n s O b j ) ;  
 }  
  
 L i v e V a l i d a t i o n . V E R S I O N   =   ' 1 . 3   s t a n d a l o n e ' ;  
  
 / * *   e l e m e n t   t y p e s   c o n s t a n t s   * * * * /  
  
 L i v e V a l i d a t i o n . T E X T A R E A   	 	 =   1 ;  
 L i v e V a l i d a t i o n . T E X T   	 	 	         =   2 ;  
 L i v e V a l i d a t i o n . P A S S W O R D   	 	 =   3 ;  
 L i v e V a l i d a t i o n . C H E C K B O X   	 	 =   4 ;  
 L i v e V a l i d a t i o n . S E L E C T   =   5 ;  
 L i v e V a l i d a t i o n . F I L E   =   6 ;  
  
 / * * * * * *   S t a t i c   m e t h o d s   * * * * * * * /  
  
 / * *  
   * 	 p a s s   a n   a r r a y   o f   L i v e V a l i d a t i o n   o b j e c t s   a n d   i t   w i l l   v a l i d a t e   a l l   o f   t h e m  
   * 	  
   * 	 @ v a r   v a l i d a t i o n s   { A r r a y }   -   a n   a r r a y   o f   L i v e V a l i d a t i o n   o b j e c t s  
   * 	 @ r e t u r n   { B o o l }   -   t r u e   i f   a l l   p a s s e d   v a l i d a t i o n ,   f a l s e   i f   a n y   f a i l 	 	 	 	 	 	  
   * /  
 L i v e V a l i d a t i o n . m a s s V a l i d a t e   =   f u n c t i o n ( v a l i d a t i o n s ) {  
     v a r   r e t u r n V a l u e   =   t r u e ;  
 	 f o r ( v a r   i   =   0 ,   l e n   =   v a l i d a t i o n s . l e n g t h ;   i   <   l e n ;   + + i   ) {  
 	 	 v a r   v a l i d   =   v a l i d a t i o n s [ i ] . v a l i d a t e ( ) ;  
 	 	 i f ( r e t u r n V a l u e )   r e t u r n V a l u e   =   v a l i d ;  
 	 }  
 	 r e t u r n   r e t u r n V a l u e ;  
 }  
  
 / * * * * * *   p r o t o t y p e   * * * * * * /  
  
 L i v e V a l i d a t i o n . p r o t o t y p e   =   {  
  
         v a l i d C l a s s :   ' L V _ v a l i d ' ,  
         i n v a l i d C l a s s :   ' L V _ i n v a l i d ' ,  
         m e s s a g e C l a s s :   ' L V _ v a l i d a t i o n _ m e s s a g e ' ,  
         v a l i d F i e l d C l a s s :   ' L V _ v a l i d _ f i e l d ' ,  
         i n v a l i d F i e l d C l a s s :   ' L V _ i n v a l i d _ f i e l d ' ,  
  
         / * *  
           * 	 i n i t i a l i s e s   a l l   o f   t h e   p r o p e r t i e s   a n d   e v e n t s  
           *  
           *   @ v a r   -   S a m e   a s   c o n s t r u c t o r   a b o v e  
           * /  
         i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ,   o p t i o n s O b j ) {  
             v a r   s e l f   =   t h i s ;  
             i f ( ! e l e m e n t )   t h r o w   n e w   E r r o r ( " L i v e V a l i d a t i o n : : i n i t i a l i z e   -   N o   e l e m e n t   r e f e r e n c e   o r   e l e m e n t   i d   h a s   b e e n   p r o v i d e d ! " ) ;  
         	 t h i s . e l e m e n t   =   e l e m e n t . n o d e N a m e   ?   e l e m e n t   :   d o c u m e n t . g e t E l e m e n t B y I d ( e l e m e n t ) ;  
         	 i f ( ! t h i s . e l e m e n t )   t h r o w   n e w   E r r o r ( " L i v e V a l i d a t i o n : : i n i t i a l i z e   -   N o   e l e m e n t   w i t h   r e f e r e n c e   o r   i d   o f   ' "   +   e l e m e n t   +   " '   e x i s t s ! " ) ;  
             / /   d e f a u l t   p r o p e r t i e s   t h a t   c o u l d   n o t   b e   i n i t i a l i s e d   a b o v e  
         	 t h i s . v a l i d a t i o n s   =   [ ] ;  
             t h i s . e l e m e n t T y p e   =   t h i s . g e t E l e m e n t T y p e ( ) ;  
             t h i s . f o r m   =   t h i s . e l e m e n t . f o r m ;  
             / /   o p t i o n s  
         	 v a r   o p t i o n s   =   o p t i o n s O b j   | |   { } ;  
         	 t h i s . v a l i d M e s s a g e   =   o p t i o n s . v a l i d M e s s a g e   | |   ' "' ;  
         	  
         	  
         	 v a r   n o d e   =   o p t i o n s . i n s e r t A f t e r W h a t N o d e   | |   t h i s . e l e m e n t ;  
 	 	 t h i s . i n s e r t A f t e r W h a t N o d e   =   n o d e . n o d e T y p e   ?   n o d e   :   d o c u m e n t . g e t E l e m e n t B y I d ( n o d e ) ;  
             t h i s . o n V a l i d   =   o p t i o n s . o n V a l i d   | |   f u n c t i o n ( ) {   t h i s . i n s e r t M e s s a g e ( t h i s . c r e a t e M e s s a g e S p a n ( ) ) ;   t h i s . a d d F i e l d C l a s s ( ) ;   } ;  
             t h i s . o n I n v a l i d   =   o p t i o n s . o n I n v a l i d   | |   f u n c t i o n ( ) {   t h i s . i n s e r t M e s s a g e ( t h i s . c r e a t e M e s s a g e S p a n ( ) ) ;   t h i s . a d d F i e l d C l a s s ( ) ;   } ; 	  
         	 t h i s . o n l y O n B l u r   =     o p t i o n s . o n l y O n B l u r   | |   f a l s e ;  
         	 t h i s . w a i t   =   o p t i o n s . w a i t   | |   0 ;  
             t h i s . o n l y O n S u b m i t   =   o p t i o n s . o n l y O n S u b m i t   | |   f a l s e ;  
             / /   a d d   t o   f o r m   i f   i t   h a s   b e e n   p r o v i d e d  
             i f ( t h i s . f o r m ) {  
                 t h i s . f o r m O b j   =   L i v e V a l i d a t i o n F o r m . g e t I n s t a n c e ( t h i s . f o r m ) ;  
                 t h i s . f o r m O b j . a d d F i e l d ( t h i s ) ;  
             }  
             / /   e v e n t s  
             / /   c o l l e c t   o l d   e v e n t s  
             t h i s . o l d O n F o c u s   =   t h i s . e l e m e n t . o n f o c u s   | |   f u n c t i o n ( ) { } ;  
             t h i s . o l d O n B l u r   =   t h i s . e l e m e n t . o n b l u r   | |   f u n c t i o n ( ) { } ;  
             t h i s . o l d O n C l i c k   =   t h i s . e l e m e n t . o n c l i c k   | |   f u n c t i o n ( ) { } ;  
             t h i s . o l d O n C h a n g e   =   t h i s . e l e m e n t . o n c h a n g e   | |   f u n c t i o n ( ) { } ;  
             t h i s . o l d O n K e y u p   =   t h i s . e l e m e n t . o n k e y u p   | |   f u n c t i o n ( ) { } ;  
             t h i s . e l e m e n t . o n f o c u s   =   f u n c t i o n ( e ) {   s e l f . d o O n F o c u s ( e ) ;   r e t u r n   s e l f . o l d O n F o c u s . c a l l ( t h i s ,   e ) ;   }  
             i f ( ! t h i s . o n l y O n S u b m i t ) {  
                 s w i t c h ( t h i s . e l e m e n t T y p e ) {  
                     c a s e   L i v e V a l i d a t i o n . C H E C K B O X :  
                         t h i s . e l e m e n t . o n c l i c k   =   f u n c t i o n ( e ) {   s e l f . v a l i d a t e ( ) ;   r e t u r n   s e l f . o l d O n C l i c k . c a l l ( t h i s ,   e ) ;   }  
                     / /   l e t   i t   r u n   i n t o   t h e   n e x t   t o   a d d   a   c h a n g e   e v e n t   t o o  
                     c a s e   L i v e V a l i d a t i o n . S E L E C T :  
                     c a s e   L i v e V a l i d a t i o n . F I L E :  
                         t h i s . e l e m e n t . o n c h a n g e   =   f u n c t i o n ( e ) {   s e l f . v a l i d a t e ( ) ;   r e t u r n   s e l f . o l d O n C h a n g e . c a l l ( t h i s ,   e ) ;   }  
                         b r e a k ;  
                     d e f a u l t :  
                         i f ( ! t h i s . o n l y O n B l u r )   t h i s . e l e m e n t . o n k e y u p   =   f u n c t i o n ( e ) {   s e l f . d e f e r V a l i d a t i o n ( ) ;   r e t u r n   s e l f . o l d O n K e y u p . c a l l ( t h i s ,   e ) ;   }  
             	         t h i s . e l e m e n t . o n b l u r   =   f u n c t i o n ( e ) {   s e l f . d o O n B l u r ( e ) ;   r e t u r n   s e l f . o l d O n B l u r . c a l l ( t h i s ,   e ) ;   }  
                 }  
             }  
         } ,  
 	  
 	 / * *  
           * 	 d e s t r o y s   t h e   i n s t a n c e ' s   e v e n t s   ( r e s t o r i n g   p r e v i o u s   o n e s )   a n d   r e m o v e s   i t   f r o m   a n y   L i v e V a l i d a t i o n F o r m s  
           * /  
         d e s t r o y :   f u n c t i o n ( ) {  
     	     i f ( t h i s . f o r m O b j ) {  
 	 	 / /   r e m o v e   t h e   f i e l d   f r o m   t h e   L i v e V a l i d a t i o n F o r m  
 	 	 t h i s . f o r m O b j . r e m o v e F i e l d ( t h i s ) ;  
 	 	 / /   d e s t r o y   t h e   L i v e V a l i d a t i o n F o r m   i f   n o   L i v e V a l i d a t i o n   f i e l d s   l e f t   i n   i t  
 	 	 t h i s . f o r m O b j . d e s t r o y ( ) ;  
 	     }  
             / /   r e m o v e   e v e n t s   -   s e t   t h e m   b a c k   t o   t h e   p r e v i o u s   e v e n t s  
 	     t h i s . e l e m e n t . o n f o c u s   =   t h i s . o l d O n F o c u s ;  
             i f ( ! t h i s . o n l y O n S u b m i t ) {  
                 s w i t c h ( t h i s . e l e m e n t T y p e ) {  
                     c a s e   L i v e V a l i d a t i o n . C H E C K B O X :  
                         t h i s . e l e m e n t . o n c l i c k   =   t h i s . o l d O n C l i c k ;  
                     / /   l e t   i t   r u n   i n t o   t h e   n e x t   t o   a d d   a   c h a n g e   e v e n t   t o o  
                     c a s e   L i v e V a l i d a t i o n . S E L E C T :  
                     c a s e   L i v e V a l i d a t i o n . F I L E :  
                         t h i s . e l e m e n t . o n c h a n g e   =   t h i s . o l d O n C h a n g e ;  
                         b r e a k ;  
                     d e f a u l t :  
                         i f ( ! t h i s . o n l y O n B l u r )   t h i s . e l e m e n t . o n k e y u p   =   t h i s . o l d O n K e y u p ;  
             	         t h i s . e l e m e n t . o n b l u r   =   t h i s . o l d O n B l u r ;  
                 }  
             }  
             t h i s . v a l i d a t i o n s   =   [ ] ;  
 	     t h i s . r e m o v e M e s s a g e A n d F i e l d C l a s s ( ) ;  
         } ,  
          
         / * *  
           * 	 a d d s   a   v a l i d a t i o n   t o   p e r f o r m   t o   a   L i v e V a l i d a t i o n   o b j e c t  
           *  
           * 	 @ v a r   v a l i d a t i o n F u n c t i o n   { F u n c t i o n }   -   v a l i d a t i o n   f u n c t i o n   t o   b e   u s e d   ( i e   V a l i d a t e . P r e s e n c e   )  
           * 	 @ v a r   v a l i d a t i o n P a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   d o i n g   t h e   v a l i d a t i o n ,   i f   w a n t e d   o r   n e c e s s a r y  
           *   @ r e t u r n   { O b j e c t }   -   t h e   L i v e V a l i d a t i o n   o b j e c t   i t s e l f   s o   t h a t   c a l l s   c a n   b e   c h a i n e d  
           * /  
         a d d :   f u n c t i o n ( v a l i d a t i o n F u n c t i o n ,   v a l i d a t i o n P a r a m s O b j ) {  
             t h i s . v a l i d a t i o n s . p u s h (   { t y p e :   v a l i d a t i o n F u n c t i o n ,   p a r a m s :   v a l i d a t i o n P a r a m s O b j   | |   { }   }   ) ;  
             r e t u r n   t h i s ;  
         } ,  
          
 	 / * *  
           * 	 r e m o v e s   a   v a l i d a t i o n   f r o m   a   L i v e V a l i d a t i o n   o b j e c t   -   m u s t   h a v e   e x a c t l y   t h e   s a m e   a r g u m e n t s   a s   u s e d   t o   a d d   i t    
           *  
           * 	 @ v a r   v a l i d a t i o n F u n c t i o n   { F u n c t i o n }   -   v a l i d a t i o n   f u n c t i o n   t o   b e   u s e d   ( i e   V a l i d a t e . P r e s e n c e   )  
           * 	 @ v a r   v a l i d a t i o n P a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   d o i n g   t h e   v a l i d a t i o n ,   i f   w a n t e d   o r   n e c e s s a r y  
           *   @ r e t u r n   { O b j e c t }   -   t h e   L i v e V a l i d a t i o n   o b j e c t   i t s e l f   s o   t h a t   c a l l s   c a n   b e   c h a i n e d  
           * /  
         r e m o v e :   f u n c t i o n ( v a l i d a t i o n F u n c t i o n ,   v a l i d a t i o n P a r a m s O b j ) {  
 	     v a r   f o u n d   =   f a l s e ;  
 	     f o r (   v a r   i   =   0 ,   l e n   =   t h i s . v a l i d a t i o n s . l e n g t h ;   i   <   l e n ;   i + +   ) {  
 	     	 	 i f (   t h i s . v a l i d a t i o n s [ i ] . t y p e   = =   v a l i d a t i o n F u n c t i o n   ) {  
 	 	 	 	 i f   ( t h i s . v a l i d a t i o n s [ i ] . p a r a m s   = =   v a l i d a t i o n P a r a m s O b j )   {  
 	 	 	 	 	 f o u n d   =   t r u e ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 }  
 	 	 	 }  
 	     }  
             i f ( f o u n d )   t h i s . v a l i d a t i o n s . s p l i c e ( i , 1 ) ;  
             r e t u r n   t h i s ;  
         } ,  
          
 	  
         / * *  
           *   m a k e s   t h e   v a l i d a t i o n   w a i t   t h e   a l o t t e d   t i m e   f r o m   t h e   l a s t   k e y s t r o k e    
           * /  
         d e f e r V a l i d a t i o n :   f u n c t i o n ( e ) {  
             i f ( t h i s . w a i t   > =   3 0 0 )   t h i s . r e m o v e M e s s a g e A n d F i e l d C l a s s ( ) ;  
         	 v a r   s e l f   =   t h i s ;  
             i f ( t h i s . t i m e o u t )   c l e a r T i m e o u t ( s e l f . t i m e o u t ) ;  
             t h i s . t i m e o u t   =   s e t T i m e o u t (   f u n c t i o n ( ) {   s e l f . v a l i d a t e ( )   } ,   s e l f . w a i t ) ;    
         } ,  
                  
         / * *  
           *   s e t s   t h e   f o c u s e d   f l a g   t o   f a l s e   w h e n   f i e l d   l o s e s   f o c u s    
           * /  
         d o O n B l u r :   f u n c t i o n ( e ) {  
             t h i s . f o c u s e d   =   f a l s e ;  
             t h i s . v a l i d a t e ( e ) ;  
         } ,  
                  
         / * *  
           *   s e t s   t h e   f o c u s e d   f l a g   t o   t r u e   w h e n   f i e l d   g a i n s   f o c u s    
           * /  
         d o O n F o c u s :   f u n c t i o n ( e ) {  
             t h i s . f o c u s e d   =   t r u e ;  
             t h i s . r e m o v e M e s s a g e A n d F i e l d C l a s s ( ) ;  
         } ,  
          
         / * *  
           * 	 g e t s   t h e   t y p e   o f   e l e m e n t ,   t o   c h e c k   w h e t h e r   i t   i s   c o m p a t i b l e  
           *  
           * 	 @ v a r   v a l i d a t i o n F u n c t i o n   { F u n c t i o n }   -   v a l i d a t i o n   f u n c t i o n   t o   b e   u s e d   ( i e   V a l i d a t e . P r e s e n c e   )  
           * 	 @ v a r   v a l i d a t i o n P a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   d o i n g   t h e   v a l i d a t i o n ,   i f   w a n t e d   o r   n e c e s s a r y  
           * /  
         g e t E l e m e n t T y p e :   f u n c t i o n ( ) {  
             s w i t c h ( t r u e ) {  
                 c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' T E X T A R E A ' ) :  
                 r e t u r n   L i v e V a l i d a t i o n . T E X T A R E A ;  
             c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' I N P U T '   & &   t h i s . e l e m e n t . t y p e . t o U p p e r C a s e ( )   = =   ' T E X T ' ) :  
                 r e t u r n   L i v e V a l i d a t i o n . T E X T ;  
             c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' I N P U T '   & &   t h i s . e l e m e n t . t y p e . t o U p p e r C a s e ( )   = =   ' P A S S W O R D ' ) :  
                 r e t u r n   L i v e V a l i d a t i o n . P A S S W O R D ;  
             c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' I N P U T '   & &   t h i s . e l e m e n t . t y p e . t o U p p e r C a s e ( )   = =   ' C H E C K B O X ' ) :  
                 r e t u r n   L i v e V a l i d a t i o n . C H E C K B O X ;  
             c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' I N P U T '   & &   t h i s . e l e m e n t . t y p e . t o U p p e r C a s e ( )   = =   ' F I L E ' ) :  
                 r e t u r n   L i v e V a l i d a t i o n . F I L E ;  
             c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' S E L E C T ' ) :  
                 r e t u r n   L i v e V a l i d a t i o n . S E L E C T ;  
                 c a s e   ( t h i s . e l e m e n t . n o d e N a m e . t o U p p e r C a s e ( )   = =   ' I N P U T ' ) :  
                 	 t h r o w   n e w   E r r o r ( ' L i v e V a l i d a t i o n : : g e t E l e m e n t T y p e   -   C a n n o t   u s e   L i v e V a l i d a t i o n   o n   a n   '   +   t h i s . e l e m e n t . t y p e   +   '   i n p u t ! ' ) ;  
                 d e f a u l t :  
                 	 t h r o w   n e w   E r r o r ( ' L i v e V a l i d a t i o n : : g e t E l e m e n t T y p e   -   E l e m e n t   m u s t   b e   a n   i n p u t ,   s e l e c t ,   o r   t e x t a r e a ! ' ) ;  
             }  
         } ,  
          
         / * *  
           * 	 l o o p s   t h r o u g h   a l l   t h e   v a l i d a t i o n s   a d d e d   t o   t h e   L i v e V a l i d a t i o n   o b j e c t   a n d   c h e c k s   t h e m   o n e   b y   o n e  
           *  
           * 	 @ v a r   v a l i d a t i o n F u n c t i o n   { F u n c t i o n }   -   v a l i d a t i o n   f u n c t i o n   t o   b e   u s e d   ( i e   V a l i d a t e . P r e s e n c e   )  
           * 	 @ v a r   v a l i d a t i o n P a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   d o i n g   t h e   v a l i d a t i o n ,   i f   w a n t e d   o r   n e c e s s a r y  
           *   @ r e t u r n   { B o o l e a n }   -   w h e t h e r   t h e   a l l   t h e   v a l i d a t i o n s   p a s s e d   o r   i f   o n e   f a i l e d  
           * /  
         d o V a l i d a t i o n s :   f u n c t i o n ( ) {  
             	 t h i s . v a l i d a t i o n F a i l e d   =   f a l s e ;  
             	 f o r ( v a r   i   =   0 ,   l e n   =   t h i s . v a l i d a t i o n s . l e n g t h ;   i   <   l e n ;   + + i ) {  
         	   	 v a r   v a l i d a t i o n   =   t h i s . v a l i d a t i o n s [ i ] ;  
         	 	 s w i t c h ( v a l i d a t i o n . t y p e ) {  
         	 	       	 c a s e   V a l i d a t e . P r e s e n c e :  
                                 c a s e   V a l i d a t e . C o n f i r m a t i o n :  
                                 c a s e   V a l i d a t e . A c c e p t a n c e :  
         	 	       	 	 t h i s . d i s p l a y M e s s a g e W h e n E m p t y   =   t r u e ;  
         	 	       	 	 t h i s . v a l i d a t i o n F a i l e d   =   ! t h i s . v a l i d a t e E l e m e n t ( v a l i d a t i o n . t y p e ,   v a l i d a t i o n . p a r a m s ) ;    
         	 	 	 	 b r e a k ;  
         	 	       	 d e f a u l t :  
         	 	       	 	 t h i s . v a l i d a t i o n F a i l e d   =   ! t h i s . v a l i d a t e E l e m e n t ( v a l i d a t i o n . t y p e ,   v a l i d a t i o n . p a r a m s ) ;  
         	 	       	 	 b r e a k ;  
         	 	 }  
         	 	 i f ( t h i s . v a l i d a t i o n F a i l e d )   r e t u r n   f a l s e ; 	  
         	 }  
         	 t h i s . m e s s a g e   =   t h i s . v a l i d M e s s a g e ;  
         	 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 p e r f o r m s   v a l i d a t i o n   o n   t h e   e l e m e n t   a n d   h a n d l e s   a n y   e r r o r   ( v a l i d a t i o n   o r   o t h e r w i s e )   i t   t h r o w s   u p  
           *  
           * 	 @ v a r   v a l i d a t i o n F u n c t i o n   { F u n c t i o n }   -   v a l i d a t i o n   f u n c t i o n   t o   b e   u s e d   ( i e   V a l i d a t e . P r e s e n c e   )  
           * 	 @ v a r   v a l i d a t i o n P a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   d o i n g   t h e   v a l i d a t i o n ,   i f   w a n t e d   o r   n e c e s s a r y  
           *   @ r e t u r n   { B o o l e a n }   -   w h e t h e r   t h e   v a l i d a t i o n   h a s   p a s s e d   o r   f a i l e d  
           * /  
         v a l i d a t e E l e m e n t :   f u n c t i o n ( v a l i d a t i o n F u n c t i o n ,   v a l i d a t i o n P a r a m s O b j ) {  
             	 v a r   v a l u e   =   ( t h i s . e l e m e n t T y p e   = =   L i v e V a l i d a t i o n . S E L E C T )   ?   t h i s . e l e m e n t . o p t i o n s [ t h i s . e l e m e n t . s e l e c t e d I n d e x ] . v a l u e   :   t h i s . e l e m e n t . v a l u e ;            
                 i f ( v a l i d a t i o n F u n c t i o n   = =   V a l i d a t e . A c c e p t a n c e ) {  
         	         i f ( t h i s . e l e m e n t T y p e   ! =   L i v e V a l i d a t i o n . C H E C K B O X )   t h r o w   n e w   E r r o r ( ' L i v e V a l i d a t i o n : : v a l i d a t e E l e m e n t   -   E l e m e n t   t o   v a l i d a t e   a c c e p t a n c e   m u s t   b e   a   c h e c k b o x ! ' ) ;  
         	 	 v a l u e   =   t h i s . e l e m e n t . c h e c k e d ;  
         	 }  
                 v a r   i s V a l i d   =   t r u e ;  
             	 t r y {          
         	 	 v a l i d a t i o n F u n c t i o n ( v a l u e ,   v a l i d a t i o n P a r a m s O b j ) ;  
         	 }   c a t c h ( e r r o r )   {  
         	     	 i f ( e r r o r   i n s t a n c e o f   V a l i d a t e . E r r o r ) {  
         	 	 	 i f (   v a l u e   ! = =   ' '   | |   ( v a l u e   = = =   ' '   & &   t h i s . d i s p l a y M e s s a g e W h e n E m p t y )   ) {  
         	 	 	 	 t h i s . v a l i d a t i o n F a i l e d   =   t r u e ;  
         	 	 	 	 t h i s . m e s s a g e   =   e r r o r . m e s s a g e ;  
         	 	 	 	 i s V a l i d   =   f a l s e ;  
         	 	 	 }  
         	 	 } e l s e {  
         	 	     	 t h r o w   e r r o r ;  
         	 	 }  
         	 } f i n a l l y {  
         	         r e t u r n   i s V a l i d ;  
                 }  
         } ,  
          
         / * *  
           * 	 m a k e s   i t   d o   t h e   a l l   t h e   v a l i d a t i o n s   a n d   f i r e s   o f f   t h e   o n V a l i d   o r   o n I n v a l i d   c a l l b a c k s  
           *  
           *   @ r e t u r n   { B o o l e a n }   -   w h e t h e r   t h e   a l l   t h e   v a l i d a t i o n s   p a s s e d   o r   i f   o n e   f a i l e d  
           * /  
         v a l i d a t e :   f u n c t i o n ( ) {  
             i f ( ! t h i s . e l e m e n t . d i s a b l e d ) {  
 	 	 v a r   i s V a l i d   =   t h i s . d o V a l i d a t i o n s ( ) ;  
 	 	 i f ( i s V a l i d ) {  
 	 	 	 t h i s . o n V a l i d ( ) ;  
 	 	 	 r e t u r n   t r u e ;  
 	 	 } e l s e   {  
 	 	 	 t h i s . o n I n v a l i d ( ) ;  
 	 	 	 r e t u r n   f a l s e ;  
 	 	 }  
 	     } e l s e {  
             r e t u r n   t r u e ;  
         }  
         } ,  
 	  
   / * *  
       *     e n a b l e s   t h e   f i e l d  
       *  
       *     @ r e t u r n   { L i v e V a l i d a t i o n }   -   t h e   L i v e V a l i d a t i o n   o b j e c t   f o r   c h a i n i n g  
       * /  
     e n a b l e :   f u n c t i o n ( ) {  
     	 t h i s . e l e m e n t . d i s a b l e d   =   f a l s e ;  
 	 r e t u r n   t h i s ;  
     } ,  
      
     / * *  
       *     d i s a b l e s   t h e   f i e l d   a n d   r e m o v e s   a n y   m e s s a g e   a n d   s t y l e s   a s s o c i a t e d   w i t h   t h e   f i e l d  
       *  
       *     @ r e t u r n   { L i v e V a l i d a t i o n }   -   t h e   L i v e V a l i d a t i o n   o b j e c t   f o r   c h a i n i n g  
       * /  
     d i s a b l e :   f u n c t i o n ( ) {  
     	 t h i s . e l e m e n t . d i s a b l e d   =   t r u e ;  
 	 t h i s . r e m o v e M e s s a g e A n d F i e l d C l a s s ( ) ;  
 	 r e t u r n   t h i s ;  
     } ,  
          
         / * *   M e s s a g e   i n s e r t i o n   m e t h o d s   * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
           *    
           *   T h e s e   a r e   o n l y   u s e d   i n   t h e   o n V a l i d   a n d   o n I n v a l i d   c a l l b a c k   f u n c t i o n s   a n d   s o   i f   y o u   o v e r i d e   t h e   d e f a u l t   c a l l b a c k s ,  
           *   y o u   m u s t   e i t h e r   i m p l i m e n t   y o u r   o w n   f u n c t i o n s   t o   d o   w h a t e v e r   y o u   w a n t ,   o r   c a l l   s o m e   o f   t h e s e   f r o m   t h e m   i f   y o u    
           *   w a n t   t o   k e e p   s o m e   o f   t h e   f u n c t i o n a l i t y  
           * /  
          
         / * *  
           * 	 m a k e s   a   s p a n   c o n t a i n g   t h e   p a s s e d   o r   f a i l e d   m e s s a g e  
           *  
           *   @ r e t u r n   { H T M L S p a n O b j e c t }   -   a   s p a n   e l e m e n t   w i t h   t h e   m e s s a g e   i n   i t  
           * /  
         c r e a t e M e s s a g e S p a n :   f u n c t i o n ( ) {  
                 v a r   s p a n   =   d o c u m e n t . c r e a t e E l e m e n t ( ' s p a n ' ) ;  
         	 v a r   t e x t N o d e   =   d o c u m e n t . c r e a t e T e x t N o d e ( t h i s . m e s s a g e ) ;  
             	 s p a n . a p p e n d C h i l d ( t e x t N o d e ) ;  
                 r e t u r n   s p a n ;  
         } ,  
          
         / * *  
           * 	 i n s e r t s   t h e   e l e m e n t   c o n t a i n i n g   t h e   m e s s a g e   i n   p l a c e   o f   t h e   e l e m e n t   t h a t   a l r e a d y   e x i s t s   ( i f   i t   d o e s )  
           *  
           *   @ v a r   e l e m e n t T o I s e r t   { H T M L E l e m e n t O b j e c t }   -   a n   e l e m e n t   n o d e   t o   i n s e r t  
           * /  
         i n s e r t M e s s a g e :   f u n c t i o n ( e l e m e n t T o I n s e r t ) {  
             	 t h i s . r e m o v e M e s s a g e ( ) ;  
             	 i f (   ( t h i s . d i s p l a y M e s s a g e W h e n E m p t y   & &   ( t h i s . e l e m e n t T y p e   = =   L i v e V a l i d a t i o n . C H E C K B O X   | |   t h i s . e l e m e n t . v a l u e   = =   ' ' ) )  
         	     | |   t h i s . e l e m e n t . v a l u e   ! =   ' '   ) {  
                         v a r   c l a s s N a m e   =   t h i s . v a l i d a t i o n F a i l e d   ?   t h i s . i n v a l i d C l a s s   :   t h i s . v a l i d C l a s s ;  
         	     	 e l e m e n t T o I n s e r t . c l a s s N a m e   + =   '   '   +   t h i s . m e s s a g e C l a s s   +   '   '   +   c l a s s N a m e ;  
                         i f ( t h i s . i n s e r t A f t e r W h a t N o d e . n e x t S i b l i n g ) {  
         	 	     	 	 t h i s . i n s e r t A f t e r W h a t N o d e . p a r e n t N o d e . i n s e r t B e f o r e ( e l e m e n t T o I n s e r t ,   t h i s . i n s e r t A f t e r W h a t N o d e . n e x t S i b l i n g ) ;  
         	 	 } e l s e {  
         	 	 	         t h i s . i n s e r t A f t e r W h a t N o d e . p a r e n t N o d e . a p p e n d C h i l d ( e l e m e n t T o I n s e r t ) ;  
         	         }  
         	 }  
         } ,  
          
          
         / * *  
           * 	 c h a n g e s   t h e   c l a s s   o f   t h e   f i e l d   b a s e d   o n   w h e t h e r   i t   i s   v a l i d   o r   n o t  
           * /  
         a d d F i e l d C l a s s :   f u n c t i o n ( ) {  
                 t h i s . r e m o v e F i e l d C l a s s ( ) ;  
                 i f ( ! t h i s . v a l i d a t i o n F a i l e d ) {  
                         i f ( t h i s . d i s p l a y M e s s a g e W h e n E m p t y   | |   t h i s . e l e m e n t . v a l u e   ! =   ' ' ) {  
                                 i f ( t h i s . e l e m e n t . c l a s s N a m e . i n d e x O f ( t h i s . v a l i d F i e l d C l a s s )   = =   - 1 )   t h i s . e l e m e n t . c l a s s N a m e   + =   '   '   +   t h i s . v a l i d F i e l d C l a s s ;  
                         }  
                 } e l s e {  
                         i f ( t h i s . e l e m e n t . c l a s s N a m e . i n d e x O f ( t h i s . i n v a l i d F i e l d C l a s s )   = =   - 1 )   t h i s . e l e m e n t . c l a s s N a m e   + =   '   '   +   t h i s . i n v a l i d F i e l d C l a s s ;  
                 }  
         } ,  
          
         / * *  
           * 	 r e m o v e s   t h e   m e s s a g e   e l e m e n t   i f   i t   e x i s t s ,   s o   t h a t   t h e   n e w   m e s s a g e   w i l l   r e p l a c e   i t  
           * /  
         r e m o v e M e s s a g e :   f u n c t i o n ( ) {  
         	 v a r   n e x t E l ;  
         	 v a r   e l   =   t h i s . i n s e r t A f t e r W h a t N o d e ;  
         	 w h i l e ( e l . n e x t S i b l i n g ) {  
         	         i f ( e l . n e x t S i b l i n g . n o d e T y p e   = = =   1 ) {  
         	 	     	 n e x t E l   =   e l . n e x t S i b l i n g ;  
         	 	     	 b r e a k ;  
         	 	 }  
         	 	 e l   =   e l . n e x t S i b l i n g ;  
         	 }  
             	 i f ( n e x t E l   & &   n e x t E l . c l a s s N a m e . i n d e x O f ( t h i s . m e s s a g e C l a s s )   ! =   - 1 )   t h i s . i n s e r t A f t e r W h a t N o d e . p a r e n t N o d e . r e m o v e C h i l d ( n e x t E l ) ;  
         } ,  
          
         / * *  
           * 	 r e m o v e s   t h e   c l a s s   t h a t   h a s   b e e n   a p p l i e d   t o   t h e   f i e l d   t o   i n d i c t e   i f   v a l i d   o r   n o t  
           * /  
         r e m o v e F i e l d C l a s s :   f u n c t i o n ( ) {  
             i f ( t h i s . e l e m e n t . c l a s s N a m e . i n d e x O f ( t h i s . i n v a l i d F i e l d C l a s s )   ! =   - 1 )   t h i s . e l e m e n t . c l a s s N a m e   =   t h i s . e l e m e n t . c l a s s N a m e . s p l i t ( t h i s . i n v a l i d F i e l d C l a s s ) . j o i n ( ' ' ) ;  
             i f ( t h i s . e l e m e n t . c l a s s N a m e . i n d e x O f ( t h i s . v a l i d F i e l d C l a s s )   ! =   - 1 )   t h i s . e l e m e n t . c l a s s N a m e   =   t h i s . e l e m e n t . c l a s s N a m e . s p l i t ( t h i s . v a l i d F i e l d C l a s s ) . j o i n ( '   ' ) ;  
         } ,  
                  
         / * *  
           * 	 r e m o v e s   t h e   m e s s a g e   a n d   t h e   f i e l d   c l a s s  
           * /  
         r e m o v e M e s s a g e A n d F i e l d C l a s s :   f u n c t i o n ( ) {  
             t h i s . r e m o v e M e s s a g e ( ) ;  
             t h i s . r e m o v e F i e l d C l a s s ( ) ;  
         }  
  
 }   / /   e n d   o f   L i v e V a l i d a t i o n   c l a s s  
  
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   L i v e V a l i d a t i o n F o r m   c l a s s   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /  
 / * *  
   *   T h i s   c l a s s   i s   u s e d   i n t e r n a l l y   b y   L i v e V a l i d a t i o n   c l a s s   t o   a s s o c i a t e   a   L i v e V a l i d a t i o n   f i e l d   w i t h   a   f o r m   i t   i s   i c o n t a i n e d   i n   o n e  
   *    
   *   I t   w i l l   t h e r e f o r e   n o t   r e a l l y   e v e r   b e   n e e d e d   t o   b e   u s e d   d i r e c t l y   b y   t h e   d e v e l o p e r ,   u n l e s s   t h e y   w a n t   t o   a s s o c i a t e   a   L i v e V a l i d a t i o n    
   *   f i e l d   w i t h   a   f o r m   t h a t   i t   i s   n o t   a   c h i l d   o f  
   * /  
  
 / * *  
       * 	 h a n d l e s   v a l i d a t i o n   o f   L i v e V a l i d a t i o n   f i e l d s   b e l o n g i n g   t o   t h i s   f o r m   o n   i t s   s u b m i t t a l  
       * 	  
       * 	 @ v a r   e l e m e n t   { H T M L F o r m E l e m e n t }   -   a   d o m   e l e m e n t   r e f e r e n c e   t o   t h e   f o r m   t o   t u r n   i n t o   a   L i v e V a l i d a t i o n F o r m  
       * /  
 v a r   L i v e V a l i d a t i o n F o r m   =   f u n c t i o n ( e l e m e n t ) {  
     t h i s . i n i t i a l i z e ( e l e m e n t ) ;  
 }  
  
 / * *  
   *   n a m e s p a c e   t o   h o l d   i n s t a n c e s  
   * /  
 L i v e V a l i d a t i o n F o r m . i n s t a n c e s   =   { } ;  
  
 / * *  
       * 	 g e t s   t h e   i n s t a n c e   o f   t h e   L i v e V a l i d a t i o n F o r m   i f   i t   h a s   a l r e a d y   b e e n   m a d e   o r   c r e a t e s   i t   i f   i t   d o e s n t   e x i s t  
       * 	  
       * 	 @ v a r   e l e m e n t   { H T M L F o r m E l e m e n t }   -   a   d o m   e l e m e n t   r e f e r e n c e   t o   a   f o r m  
       * /  
 L i v e V a l i d a t i o n F o r m . g e t I n s t a n c e   =   f u n c t i o n ( e l e m e n t ) {  
     v a r   r a n d   =   M a t h . r a n d o m ( )   *   M a t h . r a n d o m ( ) ;  
     i f ( ! e l e m e n t . i d )   e l e m e n t . i d   =   ' f o r m I d _ '   +   r a n d . t o S t r i n g ( ) . r e p l a c e ( / \ . / ,   ' ' )   +   n e w   D a t e ( ) . v a l u e O f ( ) ;  
     i f ( ! L i v e V a l i d a t i o n F o r m . i n s t a n c e s [ e l e m e n t . i d ] )   L i v e V a l i d a t i o n F o r m . i n s t a n c e s [ e l e m e n t . i d ]   =   n e w   L i v e V a l i d a t i o n F o r m ( e l e m e n t ) ;  
     r e t u r n   L i v e V a l i d a t i o n F o r m . i n s t a n c e s [ e l e m e n t . i d ] ;  
 }  
  
 L i v e V a l i d a t i o n F o r m . p r o t o t y p e   =   {  
      
     / * *  
       * 	 c o n s t r u c t o r   f o r   L i v e V a l i d a t i o n F o r m   -   h a n d l e s   v a l i d a t i o n   o f   L i v e V a l i d a t i o n   f i e l d s   b e l o n g i n g   t o   t h i s   f o r m   o n   i t s   s u b m i t t a l  
       * 	  
       * 	 @ v a r   e l e m e n t   { H T M L F o r m E l e m e n t }   -   a   d o m   e l e m e n t   r e f e r e n c e   t o   t h e   f o r m   t o   t u r n   i n t o   a   L i v e V a l i d a t i o n F o r m  
       * /  
     i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ) {  
     	 t h i s . n a m e   =   e l e m e n t . i d ;  
         t h i s . e l e m e n t   =   e l e m e n t ;  
         t h i s . f i e l d s   =   [ ] ;  
         / /   p r e s e r v e   t h e   o l d   o n s u b m i t   e v e n t  
 	 t h i s . o l d O n S u b m i t   =   t h i s . e l e m e n t . o n s u b m i t   | |   f u n c t i o n ( ) { } ;  
         v a r   s e l f   =   t h i s ;  
         t h i s . e l e m e n t . o n s u b m i t   =   f u n c t i o n ( e ) {  
             r e t u r n   ( L i v e V a l i d a t i o n . m a s s V a l i d a t e ( s e l f . f i e l d s ) )   ?   s e l f . o l d O n S u b m i t . c a l l ( t h i s ,   e   | |   w i n d o w . e v e n t )   ! = =   f a l s e   :   f a l s e ;  
         }  
     } ,  
      
     / * *  
       * 	 a d d s   a   L i v e V a l i d a t i o n   f i e l d   t o   t h e   f o r m s   f i e l d s   a r r a y  
       * 	  
       * 	 @ v a r   e l e m e n t   { L i v e V a l i d a t i o n }   -   a   L i v e V a l i d a t i o n   o b j e c t  
       * /  
     a d d F i e l d :   f u n c t i o n ( n e w F i e l d ) {  
         t h i s . f i e l d s . p u s h ( n e w F i e l d ) ;  
     } ,  
      
     / * *  
       * 	 r e m o v e s   a   L i v e V a l i d a t i o n   f i e l d   f r o m   t h e   f o r m s   f i e l d s   a r r a y  
       * 	  
       * 	 @ v a r   v i c t i m   { L i v e V a l i d a t i o n }   -   a   L i v e V a l i d a t i o n   o b j e c t  
       * /  
     r e m o v e F i e l d :   f u n c t i o n ( v i c t i m ) {  
     	 v a r   v i c t i m l e s s   =   [ ] ;  
     	 f o r (   v a r   i   =   0 ,   l e n   =   t h i s . f i e l d s . l e n g t h ;   i   <   l e n ;   i + + ) {  
 	 	 i f ( t h i s . f i e l d s [ i ]   ! = =   v i c t i m )   v i c t i m l e s s . p u s h ( t h i s . f i e l d s [ i ] ) ;  
 	 }  
         t h i s . f i e l d s   =   v i c t i m l e s s ;  
     } ,  
      
     / * *  
       * 	 d e s t r o y   t h i s   i n s t a n c e   a n d   i t s   e v e n t s  
       *  
       *   @ v a r   f o r c e   { B o o l e a n }   -   w h e t h e r   t o   f o r c e   t h e   d e t r u c t i o n   e v e n   i f   t h e r e   a r e   f i e l d s   s t i l l   a s s o c i a t e d  
       * /  
     d e s t r o y :   f u n c t i o n ( f o r c e ) {  
     	 / /   o n l y   d e s t r o y   i f   h a s   n o   f i e l d s   a n d   n o t   b e i n g   f o r c e d  
     	 i f   ( t h i s . f i e l d s . l e n g t h   ! =   0   & &   ! f o r c e )   r e t u r n   f a l s e ;  
 	 / /   r e m o v e   e v e n t s   -   s e t   b a c k   t o   p r e v i o u s   e v e n t s  
 	 t h i s . e l e m e n t . o n s u b m i t   =   t h i s . o l d O n S u b m i t ;  
 	 / /   r e m o v e   f r o m   t h e   i n s t a n c e s   n a m e s p a c e  
 	 L i v e V a l i d a t i o n F o r m . i n s t a n c e s [ t h i s . n a m e ]   =   n u l l ;  
 	 r e t u r n   t r u e ;  
     }  
        
 } / /   e n d   o f   L i v e V a l i d a t i o n F o r m   p r o t o t y p e  
  
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   V a l i d a t e   c l a s s   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /  
 / * *  
   *   T h i s   c l a s s   c o n t a i n s   a l l   t h e   m e t h o d s   n e e d e d   f o r   d o i n g   t h e   a c t u a l   v a l i d a t i o n   i t s e l f  
   *  
   *   A l l   m e t h o d s   a r e   s t a t i c   s o   t h a t   t h e y   c a n   b e   u s e d   o u t s i d e   t h e   c o n t e x t   o f   a   f o r m   f i e l d  
   *   a s   t h e y   c o u l d   b e   u s e f u l   f o r   v a l i d a t i n g   s t u f f   a n y w h e r e   y o u   w a n t   r e a l l y  
   *  
   *   A l l   o f   t h e m   w i l l   r e t u r n   t r u e   i f   t h e   v a l i d a t i o n   i s   s u c c e s s f u l ,   b u t   w i l l   r a i s e   a   V a l i d a t i o n E r r o r   i f  
   *   t h e y   f a i l ,   s o   t h a t   t h i s   c a n   b e   c a u g h t   a n d   t h e   m e s s a g e   e x p l a i n i n g   t h e   e r r o r   c a n   b e   a c c e s s e d   (   a s   j u s t    
   *   r e t u r n i n g   f a l s e   w o u l d   l e a v e   y o u   a   b i t   i n   t h e   d a r k   a s   t o   w h y   i t   f a i l e d   )  
   *  
   *   C a n   u s e   v a l i d a t i o n   m e t h o d s   a l o n e   a n d   w r a p   i n   a   t r y . . c a t c h   s t a t e m e n t   y o u r s e l f   i f   y o u   w a n t   t o   a c c e s s   t h e   f a i l u r e  
   *   m e s s a g e   a n d   h a n d l e   t h e   e r r o r ,   o r   u s e   t h e   V a l i d a t e : : n o w   m e t h o d   i f   y o u   j u s t   w a n t   t r u e   o r   f a l s e  
   * /  
  
 v a r   V a l i d a t e   =   {  
  
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   f i e l d   h a s   b e e n   f i l l e d   i n  
           *  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " C a n ' t   b e   e m p t y ! " )  
           * /  
         P r e s e n c e :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
             	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
             	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   "   " ;  
         	 i f ( v a l u e   = = =   ' '   | |   v a l u e   = = =   n u l l   | |   v a l u e   = = =   u n d e f i n e d ) {    
         	     	 V a l i d a t e . f a i l ( m e s s a g e ) ;  
         	 }  
         	 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   v a l u e   i s   n u m e r i c ,   d o e s   n o t   f a l l   w i t h i n   a   g i v e n   r a n g e   o f   n u m b e r s  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 n o t A N u m b e r M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   v a l i d a t i o n   f a i l s   w h e n   v a l u e   i s   n o t   a   n u m b e r  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   b e   a   n u m b e r ! " )  
           * 	 	 	 	 	 	 	 n o t A n I n t e g e r M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   v a l i d a t i o n   f a i l s   w h e n   v a l u e   i s   n o t   a n   i n t e g e r  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   b e   a   n u m b e r ! " )  
           * 	 	 	 	 	 	 	 w r o n g N u m b e r M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   v a l i d a t i o n   f a i l s   w h e n   i s   p a r a m   i s   u s e d  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   b e   { i s } ! " )  
           * 	 	 	 	 	 	 	 t o o L o w M e s s a g e   { S t r i n g }   	 	 -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   v a l i d a t i o n   f a i l s   w h e n   m i n i m u m   p a r a m   i s   u s e d  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   n o t   b e   l e s s   t h a n   { m i n i m u m } ! " )  
           * 	 	 	 	 	 	 	 t o o H i g h M e s s a g e   { S t r i n g }   	 -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   v a l i d a t i o n   f a i l s   w h e n   m a x i m u m   p a r a m   i s   u s e d  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   n o t   b e   m o r e   t h a n   { m a x i m u m } ! " )  
           * 	 	 	 	 	 	 	 i s   { I n t }   	 	 	 	 	 -   t h e   l e n g t h   m u s t   b e   t h i s   l o n g    
           * 	 	 	 	 	 	 	 m i n i m u m   { I n t }   	 	 	 	 -   t h e   m i n i m u m   l e n g t h   a l l o w e d  
           * 	 	 	 	 	 	 	 m a x i m u m   { I n t }   	 	 	 	 -   t h e   m a x i m u m   l e n g t h   a l l o w e d  
           *                                                   o n l y I n t e g e r   { B o o l e a n }   -   i f   t r u e   w i l l   o n l y   a l l o w   i n t e g e r s   t o   b e   v a l i d  
           *                                                                                                                           ( D E F A U L T :   f a l s e )  
           *  
           *     N B .   c a n   b e   c h e c k e d   i f   i t   i s   w i t h i n   a   r a n g e   b y   s p e c i f y i n g   b o t h   a   m i n i m u m   a n d   a   m a x i m u m  
           *     N B .   w i l l   e v a l u a t e   n u m b e r s   r e p r e s e n t e d   i n   s c i e n t i f i c   f o r m   ( i e   2 e 1 0 )   c o r r e c t l y   a s   n u m b e r s 	 	 	 	  
           * /  
         N u m e r i c a l i t y :   f u n c t i o n ( v a l u e ,   p a r a m s O b j )   {  
  
         v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   "   " ;  
         V a l i d a t e . F o r m a t ( v a l u e ,   {   f a i l u r e M e s s a g e :   m e s s a g e ,   p a t t e r n :   / ^ [ 0 - 9 \ - \   \ ( \ ) \ + ] { 3 , } $ / i   } ) ;  
         r e t u r n   t r u e ;  
 } ,  
  
  
          
         / * *  
           * 	 v a l i d a t e s   a g a i n s t   a   R e g E x p   p a t t e r n  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " N o t   v a l i d ! " )  
           * 	 	 	 	 	 	 	 p a t t e r n   { R e g E x p }   	 	 -   t h e   r e g u l a r   e x p r e s s i o n   p a t t e r n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   / . / )  
           *                           n e g a t e   { B o o l e a n }   -   i f   s e t   t o   t r u e ,   w i l l   v a l i d a t e   t r u e   i f   t h e   p a t t e r n   i s   n o t   m a t c h e d  
       *                                                       ( D E F A U L T :   f a l s e )  
           *  
           *     N B .   w i l l   r e t u r n   t r u e   f o r   a n   e m p t y   s t r i n g ,   t o   a l l o w   f o r   n o n - r e q u i r e d ,   e m p t y   f i e l d s   t o   v a l i d a t e .  
           * 	 	 I f   y o u   d o   n o t   w a n t   t h i s   t o   b e   t h e   c a s e   t h e n   y o u   m u s t   e i t h e r   a d d   a   L i v e V a l i d a t i o n . P R E S E N C E   v a l i d a t i o n  
           * 	 	 o r   b u i l d   i t   i n t o   t h e   r e g u l a r   e x p r e s s i o n   p a t t e r n  
           * /  
         F o r m a t :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
             v a r   v a l u e   =   S t r i n g ( v a l u e ) ;  
         	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   " N o t   v a l i d ! " ;  
             v a r   p a t t e r n   =   p a r a m s O b j . p a t t e r n   | |   / . / ;  
             v a r   n e g a t e   =   p a r a m s O b j . n e g a t e   | |   f a l s e ;  
             i f ( ! n e g a t e   & &   ! p a t t e r n . t e s t ( v a l u e ) )   V a l i d a t e . f a i l ( m e s s a g e ) ;   / /   n o r m a l  
             i f ( n e g a t e   & &   p a t t e r n . t e s t ( v a l u e ) )   V a l i d a t e . f a i l ( m e s s a g e ) ;   / /   n e g a t e d  
         	 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   f i e l d   c o n t a i n s   a   v a l i d   e m a i l   a d d r e s s  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " M u s t   b e   a   n u m b e r ! "   o r   " M u s t   b e   a n   i n t e g e r ! " )  
           * /  
         E m a i l :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
         	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   "   " ;  
         	 V a l i d a t e . F o r m a t ( v a l u e ,   {   f a i l u r e M e s s a g e :   m e s s a g e ,   p a t t e r n :   / ^ ( [ ^ @ \ s ] + ) @ ( ( ? : [ - a - z 0 - 9 ] + \ . ) + [ a - z ] { 2 , } ) $ / i   }   ) ;  
         	 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h e   l e n g t h   o f   t h e   v a l u e  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 w r o n g L e n g t h M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f a i l s   w h e n   i s   p a r a m   i s   u s e d  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   b e   { i s }   c h a r a c t e r s   l o n g ! " )  
           * 	 	 	 	 	 	 	 t o o S h o r t M e s s a g e   { S t r i n g }   	 -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f a i l s   w h e n   m i n i m u m   p a r a m   i s   u s e d  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   n o t   b e   l e s s   t h a n   { m i n i m u m }   c h a r a c t e r s   l o n g ! " )  
           * 	 	 	 	 	 	 	 t o o L o n g M e s s a g e   { S t r i n g }   	 -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f a i l s   w h e n   m a x i m u m   p a r a m   i s   u s e d  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     	     ( D E F A U L T :   " M u s t   n o t   b e   m o r e   t h a n   { m a x i m u m }   c h a r a c t e r s   l o n g ! " )  
           * 	 	 	 	 	 	 	 i s   { I n t }   	 	 	 	 	 -   t h e   l e n g t h   m u s t   b e   t h i s   l o n g    
           * 	 	 	 	 	 	 	 m i n i m u m   { I n t }   	 	 	 	 -   t h e   m i n i m u m   l e n g t h   a l l o w e d  
           * 	 	 	 	 	 	 	 m a x i m u m   { I n t }   	 	 	 	 -   t h e   m a x i m u m   l e n g t h   a l l o w e d  
           *  
           *     N B .   c a n   b e   c h e c k e d   i f   i t   i s   w i t h i n   a   r a n g e   b y   s p e c i f y i n g   b o t h   a   m i n i m u m   a n d   a   m a x i m u m 	 	 	 	  
           * /  
         L e n g t h :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
         	 v a r   v a l u e   =   S t r i n g ( v a l u e ) ;  
         	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
                 v a r   m i n i m u m   =   ( ( p a r a m s O b j . m i n i m u m )   | |   ( p a r a m s O b j . m i n i m u m   = =   0 ) )   ?   p a r a m s O b j . m i n i m u m   :   n u l l ;  
         	 v a r   m a x i m u m   =   ( ( p a r a m s O b j . m a x i m u m )   | |   ( p a r a m s O b j . m a x i m u m   = =   0 ) )   ?   p a r a m s O b j . m a x i m u m   :   n u l l ;  
         	 v a r   i s   =   ( ( p a r a m s O b j . i s )   | |   ( p a r a m s O b j . i s   = =   0 ) )   ?   p a r a m s O b j . i s   :   n u l l ;  
                 v a r   w r o n g L e n g t h M e s s a g e   =   p a r a m s O b j . w r o n g L e n g t h M e s s a g e   | |   " M u s t   b e   "   +   i s   +   "   c h a r a c t e r s   l o n g ! " ;  
         	 v a r   t o o S h o r t M e s s a g e   =   p a r a m s O b j . t o o S h o r t M e s s a g e   | |   "   " ;  
         	 v a r   t o o L o n g M e s s a g e   =   p a r a m s O b j . t o o L o n g M e s s a g e   | |   " M u s t   n o t   b e   m o r e   t h a n   "   +   m a x i m u m   +   "   c h a r a c t e r s   l o n g ! " ;  
         	 s w i t c h ( t r u e ) {  
         	     	 c a s e   ( i s   ! = =   n u l l ) :  
         	     	 	 i f (   v a l u e . l e n g t h   ! =   N u m b e r ( i s )   )   V a l i d a t e . f a i l ( w r o n g L e n g t h M e s s a g e ) ;  
         	 	 	 b r e a k ;  
         	     	 c a s e   ( m i n i m u m   ! = =   n u l l   & &   m a x i m u m   ! = =   n u l l ) :  
         	     	 	 V a l i d a t e . L e n g t h ( v a l u e ,   { t o o S h o r t M e s s a g e :   t o o S h o r t M e s s a g e ,   m i n i m u m :   m i n i m u m } ) ;  
         	     	 	 V a l i d a t e . L e n g t h ( v a l u e ,   { t o o L o n g M e s s a g e :   t o o L o n g M e s s a g e ,   m a x i m u m :   m a x i m u m } ) ;  
         	     	 	 b r e a k ;  
         	     	 c a s e   ( m i n i m u m   ! = =   n u l l ) :  
         	     	 	 i f (   v a l u e . l e n g t h   <   N u m b e r ( m i n i m u m )   )   V a l i d a t e . f a i l ( t o o S h o r t M e s s a g e ) ;  
         	 	 	 b r e a k ;  
         	     	 c a s e   ( m a x i m u m   ! = =   n u l l ) :  
         	     	 	 i f (   v a l u e . l e n g t h   >   N u m b e r ( m a x i m u m )   )   V a l i d a t e . f a i l ( t o o L o n g M e s s a g e ) ;  
         	 	 	 b r e a k ;  
         	 	 d e f a u l t :  
         	 	 	 t h r o w   n e w   E r r o r ( " V a l i d a t e : : L e n g t h   -   L e n g t h ( s )   t o   v a l i d a t e   a g a i n s t   m u s t   b e   p r o v i d e d ! " ) ;  
         	 }  
         	  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   v a l u e   f a l l s   w i t h i n   a   g i v e n   s e t   o f   v a l u e s  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " M u s t   b e   i n c l u d e d   i n   t h e   l i s t ! " )  
           * 	 	 	 	 	 	 	 w i t h i n   { A r r a y }   	 	 	 -   a n   a r r a y   o f   v a l u e s   t h a t   t h e   v a l u e   s h o u l d   f a l l   i n    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   [ ] ) 	  
           * 	 	 	 	 	 	 	 a l l o w N u l l   { B o o l }   	 	 -   i f   t r u e ,   a n d   a   n u l l   v a l u e   i s   p a s s e d   i n ,   v a l i d a t e s   a s   t r u e  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f a l s e )  
           *                           p a r t i a l M a t c h   { B o o l }   	 -   i f   t r u e ,   w i l l   n o t   o n l y   v a l i d a t e   a g a i n s t   t h e   w h o l e   v a l u e   t o   c h e c k   b u t   a l s o   i f   i t   i s   a   s u b s t r i n g   o f   t h e   v a l u e    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f a l s e )  
           *                           c a s e S e n s i t i v e   { B o o l }   -   i f   f a l s e   w i l l   c o m p a r e   s t r i n g s   c a s e   i n s e n s i t i v e l y  
           *                                                     ( D E F A U L T :   t r u e )  
           *                           n e g a t e   { B o o l }   	 	 -   i f   t r u e ,   w i l l   v a l i d a t e   t h a t   t h e   v a l u e   i s   n o t   w i t h i n   t h e   g i v e n   s e t   o f   v a l u e s  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f a l s e ) 	 	 	  
           * /  
         I n c l u s i o n :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
         	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   " M u s t   b e   i n c l u d e d   i n   t h e   l i s t ! " ;  
             v a r   c a s e S e n s i t i v e   =   ( p a r a m s O b j . c a s e S e n s i t i v e   = = =   f a l s e )   ?   f a l s e   :   t r u e ;  
         	 i f ( p a r a m s O b j . a l l o w N u l l   & &   v a l u e   = =   n u l l )   r e t u r n   t r u e ;  
             i f ( ! p a r a m s O b j . a l l o w N u l l   & &   v a l u e   = =   n u l l )   V a l i d a t e . f a i l ( m e s s a g e ) ;  
         	 v a r   w i t h i n   =   p a r a m s O b j . w i t h i n   | |   [ ] ;  
             / / i f   c a s e   i n s e n s i t i v e ,   m a k e   a l l   s t r i n g s   i n   t h e   a r r a y   l o w e r c a s e ,   a n d   t h e   v a l u e   t o o  
             i f ( ! c a s e S e n s i t i v e ) {    
                 v a r   l o w e r W i t h i n   =   [ ] ;  
                 f o r ( v a r   j   =   0 ,   l e n g t h   =   w i t h i n . l e n g t h ;   j   <   l e n g t h ;   + + j ) {  
                 	 v a r   i t e m   =   w i t h i n [ j ] ;  
                     i f ( t y p e o f   i t e m   = =   ' s t r i n g ' )   i t e m   =   i t e m . t o L o w e r C a s e ( ) ;  
                     l o w e r W i t h i n . p u s h ( i t e m ) ;  
                 }  
                 w i t h i n   =   l o w e r W i t h i n ;  
                 i f ( t y p e o f   v a l u e   = =   ' s t r i n g ' )   v a l u e   =   v a l u e . t o L o w e r C a s e ( ) ;  
             }  
         	 v a r   f o u n d   =   f a l s e ;  
         	 f o r ( v a r   i   =   0 ,   l e n g t h   =   w i t h i n . l e n g t h ;   i   <   l e n g t h ;   + + i ) {  
         	     i f ( w i t h i n [ i ]   = =   v a l u e )   f o u n d   =   t r u e ;  
                 i f ( p a r a m s O b j . p a r t i a l M a t c h ) {    
                     i f ( v a l u e . i n d e x O f ( w i t h i n [ i ] )   ! =   - 1 )   f o u n d   =   t r u e ;  
                 }  
         	 }  
         	 i f (   ( ! p a r a m s O b j . n e g a t e   & &   ! f o u n d )   | |   ( p a r a m s O b j . n e g a t e   & &   f o u n d )   )   V a l i d a t e . f a i l ( m e s s a g e ) ;  
         	 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   v a l u e   d o e s   n o t   f a l l   w i t h i n   a   g i v e n   s e t   o f   v a l u e s  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " M u s t   n o t   b e   i n c l u d e d   i n   t h e   l i s t ! " )  
           * 	 	 	 	 	 	 	 w i t h i n   { A r r a y }   	 	 	 -   a n   a r r a y   o f   v a l u e s   t h a t   t h e   v a l u e   s h o u l d   n o t   f a l l   i n    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   [ ] )  
           * 	 	 	 	 	 	 	 a l l o w N u l l   { B o o l }   	 	 -   i f   t r u e ,   a n d   a   n u l l   v a l u e   i s   p a s s e d   i n ,   v a l i d a t e s   a s   t r u e  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f a l s e )  
           *                           p a r t i a l M a t c h   { B o o l }   	 -   i f   t r u e ,   w i l l   n o t   o n l y   v a l i d a t e   a g a i n s t   t h e   w h o l e   v a l u e   t o   c h e c k   b u t   a l s o   i f   i t   i s   a   s u b s t r i n g   o f   t h e   v a l u e    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f a l s e )  
           *                           c a s e S e n s i t i v e   { B o o l }   -   i f   f a l s e   w i l l   c o m p a r e   s t r i n g s   c a s e   i n s e n s i t i v e l y  
           *                                                     ( D E F A U L T :   t r u e ) 	 	 	  
           * /  
         E x c l u s i o n :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
             v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         	 p a r a m s O b j . f a i l u r e M e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   " " ;  
             p a r a m s O b j . n e g a t e   =   t r u e ;  
         	 V a l i d a t e . I n c l u s i o n ( v a l u e ,   p a r a m s O b j ) ;  
             r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   v a l u e   m a t c h e s   t h a t   i n   a n o t h e r   f i e l d  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " D o e s   n o t   m a t c h ! " )  
           * 	 	 	 	 	 	 	 m a t c h   { S t r i n g }   	 	 	 -   i d   o f   t h e   f i e l d   t h a t   t h i s   o n e   s h o u l d   m a t c h 	 	 	 	 	 	  
           * /    
         C o n f i r m a t i o n :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
             	 i f ( ! p a r a m s O b j . m a t c h )   t h r o w   n e w   E r r o r ( " V a l i d a t e : : C o n f i r m a t i o n   -   E r r o r   v a l i d a t i n g   c o n f i r m a t i o n :   I d   o f   e l e m e n t   t o   m a t c h   m u s t   b e   p r o v i d e d ! " ) ;  
         	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   "   " ;  
         	 v a r   m a t c h   =   p a r a m s O b j . m a t c h . n o d e N a m e   ?   p a r a m s O b j . m a t c h   :   d o c u m e n t . g e t E l e m e n t B y I d ( p a r a m s O b j . m a t c h ) ;  
         	 i f ( ! m a t c h )   t h r o w   n e w   E r r o r ( " V a l i d a t e : : C o n f i r m a t i o n   -   T h e r e   i s   n o   r e f e r e n c e   w i t h   n a m e   o f ,   o r   e l e m e n t   w i t h   i d   o f   ' "   +   p a r a m s O b j . m a t c h   +   " ' ! " ) ;  
         	 i f ( v a l u e   ! =   m a t c h . v a l u e ) {    
         	     	 V a l i d a t e . f a i l ( m e s s a g e ) ;  
         	 }  
         	 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           * 	 v a l i d a t e s   t h a t   t h e   v a l u e   i s   t r u e   ( f o r   u s e   p r i m a r i l y   i n   d e t e m i n i n g   i f   a   c h e c k b o x   h a s   b e e n   c h e c k e d )  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d   i f   t r u e   o r   n o t   ( u s u a l l y   a   b o o l e a n   f r o m   t h e   c h e c k e d   v a l u e   o f   a   c h e c k b o x )  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " M u s t   b e   a c c e p t e d ! " )  
           * /  
         A c c e p t a n c e :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
             	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
         	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   " M u s t   b e   a c c e p t e d ! " ;  
         	 i f ( ! v a l u e ) {    
         	     	 V a l i d a t e . f a i l ( m e s s a g e ) ;  
         	 }  
         	 r e t u r n   t r u e ;  
         } ,  
          
 	   / * *  
           * 	 v a l i d a t e s   a g a i n s t   a   c u s t o m   f u n c t i o n   t h a t   r e t u r n s   t r u e   o r   f a l s e   ( o r   t h r o w s   a   V a l i d a t e . E r r o r )   w h e n   p a s s e d   t h e   v a l u e  
           * 	  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d  
           * 	 @ v a r   p a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   t h i s   p a r t i c u l a r   v a l i d a t i o n ,   s e e   b e l o w   f o r   d e t a i l s  
           *  
           * 	 p a r a m s O b j   p r o p e r t i e s :  
           * 	 	 	 	 	 	 	 f a i l u r e M e s s a g e   { S t r i n g }   -   t h e   m e s s a g e   t o   s h o w   w h e n   t h e   f i e l d   f a i l s   v a l i d a t i o n  
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   " N o t   v a l i d ! " )  
           * 	 	 	 	 	 	 	 a g a i n s t   { F u n c t i o n }   	 	 	 -   a   f u n c t i o n   t h a t   w i l l   t a k e   t h e   v a l u e   a n d   o b j e c t   o f   a r g u m e n t s   a n d   r e t u r n   t r u e   o r   f a l s e    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   f u n c t i o n ( ) {   r e t u r n   t r u e ;   } )  
           * 	 	 	 	 	 	 	 a r g s   { O b j e c t }   	 	 -   a n   o b j e c t   o f   n a m e d   a r g u m e n t s   t h a t   w i l l   b e   p a s s e d   t o   t h e   c u s t o m   f u n c t i o n   s o   a r e   a c c e s s i b l e   t h r o u g h   t h i s   o b j e c t   w i t h i n   i t    
           * 	 	 	 	 	 	 	 	 	 	 	 	 	     ( D E F A U L T :   { } )  
           * /  
 	 C u s t o m :   f u n c t i o n ( v a l u e ,   p a r a m s O b j ) {  
 	 	 v a r   p a r a m s O b j   =   p a r a m s O b j   | |   { } ;  
 	 	 v a r   a g a i n s t   =   p a r a m s O b j . a g a i n s t   | |   f u n c t i o n ( ) {   r e t u r n   t r u e ;   } ;  
 	 	 v a r   a r g s   =   p a r a m s O b j . a r g s   | |   { } ;  
 	 	 v a r   m e s s a g e   =   p a r a m s O b j . f a i l u r e M e s s a g e   | |   " N o t   v a l i d ! " ;  
 	         i f ( ! a g a i n s t ( v a l u e ,   a r g s ) )   V a l i d a t e . f a i l ( m e s s a g e ) ;  
 	         r e t u r n   t r u e ;  
 	     } ,  
 	  
         / * *  
           * 	 v a l i d a t e s   w h a t e v e r   i t   i s   y o u   p a s s   i n ,   a n d   h a n d l e s   t h e   v a l i d a t i o n   e r r o r   f o r   y o u   s o   i t   g i v e s   a   n i c e   t r u e   o r   f a l s e   r e p l y  
           *  
           * 	 @ v a r   v a l i d a t i o n F u n c t i o n   { F u n c t i o n }   -   v a l i d a t i o n   f u n c t i o n   t o   b e   u s e d   ( i e   V a l i d a t i o n . v a l i d a t e P r e s e n c e   )  
           * 	 @ v a r   v a l u e   { m i x e d }   -   v a l u e   t o   b e   c h e c k e d   i f   t r u e   o r   n o t   ( u s u a l l y   a   b o o l e a n   f r o m   t h e   c h e c k e d   v a l u e   o f   a   c h e c k b o x )  
           * 	 @ v a r   v a l i d a t i o n P a r a m s O b j   { O b j e c t }   -   p a r a m e t e r s   f o r   d o i n g   t h e   v a l i d a t i o n ,   i f   w a n t e d   o r   n e c e s s a r y  
           * /  
         n o w :   f u n c t i o n ( v a l i d a t i o n F u n c t i o n ,   v a l u e ,   v a l i d a t i o n P a r a m s O b j ) {  
             	 i f ( ! v a l i d a t i o n F u n c t i o n )   t h r o w   n e w   E r r o r ( " V a l i d a t e : : n o w   -   V a l i d a t i o n   f u n c t i o n   m u s t   b e   p r o v i d e d ! " ) ;  
         	 v a r   i s V a l i d   =   t r u e ;  
                 t r y {          
         	 	 v a l i d a t i o n F u n c t i o n ( v a l u e ,   v a l i d a t i o n P a r a m s O b j   | |   { } ) ;  
         	 }   c a t c h ( e r r o r )   {  
         	 	 i f ( e r r o r   i n s t a n c e o f   V a l i d a t e . E r r o r ) {  
         	 	 	 i s V a l i d   =     f a l s e ;  
         	 	 } e l s e {  
         	 	   	 t h r o w   e r r o r ;  
         	 	 }  
         	 } f i n a l l y {    
                         r e t u r n   i s V a l i d    
                 }  
         } ,  
          
         / * *  
           *   s h o r t c u t   f o r   f a i l i n g   t h r o w i n g   a   v a l i d a t i o n   e r r o r  
           *  
           * 	 @ v a r   e r r o r M e s s a g e   { S t r i n g }   -   m e s s a g e   t o   d i s p l a y  
           * /  
         f a i l :   f u n c t i o n ( e r r o r M e s s a g e ) {  
                         t h r o w   n e w   V a l i d a t e . E r r o r ( e r r o r M e s s a g e ) ;  
         } ,  
          
         E r r o r :   f u n c t i o n ( e r r o r M e s s a g e ) {  
         	 t h i s . m e s s a g e   =   e r r o r M e s s a g e ;  
         	 t h i s . n a m e   =   ' V a l i d a t i o n E r r o r ' ;  
         }  
  
 } 
