ÿþ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 ( B , A ) { t h i s . i n i t i a l i z e ( B , A ) ; } ; 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 " ; 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 ; 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 ( C ) { v a r   D = t r u e ; f o r ( v a r   B = 0 , A = C . l e n g t h ; B < A ; + + B ) { v a r   E = C [ B ] . v a l i d a t e ( ) ; i f ( D ) { D = E ; } } r e t u r n   D ; } ; 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 z e : f u n c t i o n ( D , C ) { v a r   A = t h i s ; i f ( ! D ) { 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 = D . n o d e N a m e ? D : d o c u m e n t . g e t E l e m e n t B y I d ( D ) ; 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   ' " + D + " '   e x i s t s ! " ) ; } 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 ; v a r   B = C | | { } ; t h i s . v a l i d M e s s a g e = B . v a l i d M e s s a g e | | " " ; v a r   E = B . 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 = E . n o d e T y p e ? E : d o c u m e n t . g e t E l e m e n t B y I d ( E ) ; t h i s . o n V a l i d = B . 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 = B . 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 = B . o n l y O n B l u r | | f a l s e ; t h i s . w a i t = B . w a i t | | 0 ; t h i s . o n l y O n S u b m i t = B . o n l y O n S u b m i t | | f a l s e ; 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 ) ; } 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 ( F ) { A . d o O n F o c u s ( F ) ; r e t u r n   A . o l d O n F o c u s . c a l l ( t h i s , F ) ; } ; 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 ( F ) { A . v a l i d a t e ( ) ; r e t u r n   A . o l d O n C l i c k . c a l l ( t h i s , F ) ; } ; 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 ( F ) { A . v a l i d a t e ( ) ; r e t u r n   A . o l d O n C h a n g e . c a l l ( t h i s , F ) ; } ; 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 ( F ) { A . d e f e r V a l i d a t i o n ( ) ; r e t u r n   A . o l d O n K e y u p . c a l l ( t h i s , F ) ; } ; } 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 ( F ) { A . d o O n B l u r ( F ) ; r e t u r n   A . o l d O n B l u r . c a l l ( t h i s , F ) ; } ; } } } , 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 ) { 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 ) ; t h i s . f o r m O b j . d e s t r o y ( ) ; } 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 ; 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 : f u n c t i o n ( A , B ) { t h i s . v a l i d a t i o n s . p u s h ( { t y p e : A , p a r a m s : B | | { } } ) ; r e t u r n   t h i s ; } , r e m o v e : f u n c t i o n ( B , D ) { v a r   E = f a l s e ; f o r ( v a r   C = 0 , A = t h i s . v a l i d a t i o n s . l e n g t h ; C < A ; C + + ) { i f ( t h i s . v a l i d a t i o n s [ C ] . t y p e = = B ) { i f ( t h i s . v a l i d a t i o n s [ C ] . p a r a m s = = D ) { E = t r u e ; b r e a k ; } } } i f ( E ) { t h i s . v a l i d a t i o n s . s p l i c e ( C , 1 ) ; } r e t u r n   t h i s ; } , d e f e r V a l i d a t i o n : f u n c t i o n ( B ) { 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   A = 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 ( A . 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 ( ) { A . v a l i d a t e ( ) ; } , A . w a i t ) ; } , d o O n B l u r : f u n c t i o n ( A ) { 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 ( A ) ; } , d o O n F o c u s : f u n c t i o n ( A ) { 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 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 ! " ) ; } } , 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   C = 0 , A = t h i s . v a l i d a t i o n s . l e n g t h ; C < A ; + + C ) { v a r   B = t h i s . v a l i d a t i o n s [ C ] ; s w i t c h ( B . 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 ( B . t y p e , B . 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 ( B . t y p e , B . 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 ; } , v a l i d a t e E l e m e n t : f u n c t i o n ( A , C ) { v a r   D = ( 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 ( A = = 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 ! " ) ; } D = t h i s . e l e m e n t . c h e c k e d ; } v a r   E = t r u e ; t r y { A ( D , C ) ; } c a t c h ( B ) { i f ( B   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 ( D ! = = " " | | ( D = = = " " & & 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 = B . m e s s a g e ; E = f a l s e ; } } e l s e { t h r o w   B ; } } f i n a l l y { r e t u r n   E ; } } , 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   A = t h i s . d o V a l i d a t i o n s ( ) ; i f ( A ) { 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 : 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 : 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 ; } , 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   A = 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   B = 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 ) ; A . a p p e n d C h i l d ( B ) ; r e t u r n   A ; } , i n s e r t M e s s a g e : f u n c t i o n ( B ) { 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   A = 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 ; B . 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 + "   " + A ; 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 ( B , 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 ( B ) ; } } } , 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 M e s s a g e : f u n c t i o n ( ) { v a r   A ; v a r   B = 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 ( B . n e x t S i b l i n g ) { i f ( B . n e x t S i b l i n g . n o d e T y p e = = = 1 ) { A = B . n e x t S i b l i n g ; b r e a k ; } B = B . n e x t S i b l i n g ; } i f ( A & & A . 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 ( A ) ; } } , 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 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 ( ) ; } } ; 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 ( A ) { t h i s . i n i t i a l i z e ( A ) ; } ; 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 = { } ; 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 ( A ) { v a r   B = M a t h . r a n d o m ( ) * M a t h . r a n d o m ( ) ; i f ( ! A . i d ) { A . i d = " f o r m I d _ " + B . 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 [ A . 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 [ A . i d ] = n e w   L i v e V a l i d a t i o n F o r m ( A ) ; } 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 [ A . 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 = { i n i t i a l i z e : f u n c t i o n ( B ) { t h i s . n a m e = B . i d ; t h i s . e l e m e n t = B ; t h i s . f i e l d s = [ ] ; 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   A = 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 ( C ) { 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 ( A . f i e l d s ) ) ? A . o l d O n S u b m i t . c a l l ( t h i s , C | | w i n d o w . e v e n t ) ! = = f a l s e : f a l s e ; } ; } , a d d F i e l d : f u n c t i o n ( A ) { t h i s . f i e l d s . p u s h ( A ) ; } , r e m o v e F i e l d : f u n c t i o n ( C ) { v a r   D = [ ] ; f o r ( v a r   B = 0 , A = t h i s . f i e l d s . l e n g t h ; B < A ; B + + ) { i f ( t h i s . f i e l d s [ B ] ! = = C ) { D . p u s h ( t h i s . f i e l d s [ B ] ) ; } } t h i s . f i e l d s = D ; } , d e s t r o y : f u n c t i o n ( A ) { i f ( t h i s . f i e l d s . l e n g t h ! = 0 & & ! A ) { r e t u r n   f a l s e ; } 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 ; 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 ; } } ; v a r   V a l i d a t e = { P r e s e n c e : f u n c t i o n ( B , C ) { v a r   C = C | | { } ; v a r   A = C . f a i l u r e M e s s a g e | | " ÷‹kX™Qÿ" ; i f ( B = = = " " | | B = = = n u l l | | B = = = u n d e f i n e d ) { V a l i d a t e . f a i l ( A ) ; } r e t u r n   t r u e ; } , N u m e r i c a l i t y : f u n c t i o n ( J , E ) { v a r   A = J ; v a r   J = N u m b e r ( J ) ; v a r   E = E | | { } ; v a r   F = ( ( E . m i n i m u m ) | | ( E . m i n i m u m = = 0 ) ) ? E . m i n i m u m : n u l l ; v a r   C = ( ( E . m a x i m u m ) | | ( E . m a x i m u m = = 0 ) ) ? E . m a x i m u m : n u l l ; v a r   D = ( ( E . i s ) | | ( E . i s = = 0 ) ) ? E . i s : n u l l ; v a r   G = E . n o t A N u m b e r M e s s a g e | | " ÷‹kX™QpeW[ÿÿ" ; v a r   H = E . n o t A n I n t e g e r M e s s a g e | | " ÷‹kX™Qtepeÿÿ" ; v a r   I = E . w r o n g N u m b e r M e s s a g e | | " M u s t   b e   " + D + " ! " ; v a r   B = E . t o o L o w M e s s a g e | | " Ný€\ŽN  " + F + " ! " ; v a r   K = E . t o o H i g h M e s s a g e | | " Ný€'YŽN  " + C + " ! " ; i f ( ! i s F i n i t e ( J ) ) { V a l i d a t e . f a i l ( G ) ; } i f ( E . o n l y I n t e g e r & & ( / \ . 0 + $ | \ . $ / . t e s t ( S t r i n g ( A ) ) | | J ! = p a r s e I n t ( J ) ) ) { V a l i d a t e . f a i l ( H ) ; } s w i t c h ( t r u e ) { c a s e   ( D ! = = n u l l ) : i f ( J ! = N u m b e r ( D ) ) { V a l i d a t e . f a i l ( I ) ; } b r e a k ; c a s e   ( F ! = = n u l l & & C ! = = n u l l ) : V a l i d a t e . N u m e r i c a l i t y ( J , { t o o L o w M e s s a g e : B , m i n i m u m : F } ) ; V a l i d a t e . N u m e r i c a l i t y ( J , { t o o H i g h M e s s a g e : K , m a x i m u m : C } ) ; b r e a k ; c a s e   ( F ! = = n u l l ) : i f ( J < N u m b e r ( F ) ) { V a l i d a t e . f a i l ( B ) ; } b r e a k ; c a s e   ( C ! = = n u l l ) : i f ( J > N u m b e r ( C ) ) { V a l i d a t e . f a i l ( K ) ; } b r e a k ; } r e t u r n   t r u e ; } , F o r m a t : f u n c t i o n ( C , E ) { v a r   C = S t r i n g ( C ) ; v a r   E = E | | { } ; v a r   A = E . 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   B = E . p a t t e r n | | / . / ; v a r   D = E . n e g a t e | | f a l s e ; i f ( ! D & & ! B . t e s t ( C ) ) { V a l i d a t e . f a i l ( A ) ; } i f ( D & & B . t e s t ( C ) ) { V a l i d a t e . f a i l ( A ) ; } r e t u r n   t r u e ; } , E m a i l : f u n c t i o n ( B , C ) { v a r   C = C | | { } ; v a r   A = C . f a i l u r e M e s s a g e | | " E m a i l <h_Ncknxÿÿ" ; V a l i d a t e . F o r m a t ( B , { f a i l u r e M e s s a g e : A , 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 ; } , L e n g t h : f u n c t i o n ( F , G ) { v a r   F = S t r i n g ( F ) ; v a r   G = G | | { } ; v a r   E = ( ( G . m i n i m u m ) | | ( G . m i n i m u m = = 0 ) ) ? G . m i n i m u m : n u l l ; v a r   H = ( ( G . m a x i m u m ) | | ( G . m a x i m u m = = 0 ) ) ? G . m a x i m u m : n u l l ; v a r   C = ( ( G . i s ) | | ( G . i s = = 0 ) ) ? G . i s : n u l l ; v a r   A = G . w r o n g L e n g t h M e s s a g e | | " Å_{˜:N  " + C + "   *NW[&{ÿÿ" ; v a r   B = G . t o o S h o r t M e s s a g e | | " Ný€\ŽN  " + E + "   *NW[&{ÿÿ" ; v a r   D = G . t o o L o n g M e s s a g e | | " Ný€YŽN  " + H + "   *NW[&{ÿÿ" ; s w i t c h ( t r u e ) { c a s e   ( C ! = = n u l l ) : i f ( F . l e n g t h ! = N u m b e r ( C ) ) { V a l i d a t e . f a i l ( A ) ; } b r e a k ; c a s e   ( E ! = = n u l l & & H ! = = n u l l ) : V a l i d a t e . L e n g t h ( F , { t o o S h o r t M e s s a g e : B , m i n i m u m : E } ) ; V a l i d a t e . L e n g t h ( F , { t o o L o n g M e s s a g e : D , m a x i m u m : H } ) ; b r e a k ; c a s e   ( E ! = = n u l l ) : i f ( F . l e n g t h < N u m b e r ( E ) ) { V a l i d a t e . f a i l ( B ) ; } b r e a k ; c a s e   ( H ! = = n u l l ) : i f ( F . l e n g t h > N u m b e r ( H ) ) { V a l i d a t e . f a i l ( D ) ; } 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 ! " ) ; } r e t u r n   t r u e ; } , I n c l u s i o n : f u n c t i o n ( H , F ) { v a r   F = F | | { } ; v a r   K = F . 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   G = ( F . 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 ( F . a l l o w N u l l & & H = = n u l l ) { r e t u r n   t r u e ; } i f ( ! F . a l l o w N u l l & & H = = n u l l ) { V a l i d a t e . f a i l ( K ) ; } v a r   D = F . w i t h i n | | [ ] ; i f ( ! G ) { v a r   A = [ ] ; f o r ( v a r   C = 0 , B = D . l e n g t h ; C < B ; + + C ) { v a r   I = D [ C ] ; i f ( t y p e o f   I = = " s t r i n g " ) { I = I . t o L o w e r C a s e ( ) ; } A . p u s h ( I ) ; } D = A ; i f ( t y p e o f   H = = " s t r i n g " ) { H = H . t o L o w e r C a s e ( ) ; } } v a r   J = f a l s e ; f o r ( v a r   E = 0 , B = D . l e n g t h ; E < B ; + + E ) { i f ( D [ E ] = = H ) { J = t r u e ; } i f ( F . p a r t i a l M a t c h ) { i f ( H . i n d e x O f ( D [ E ] ) ! = - 1 ) { J = t r u e ; } } } i f ( ( ! F . n e g a t e & & ! J ) | | ( F . n e g a t e & & J ) ) { V a l i d a t e . f a i l ( K ) ; } r e t u r n   t r u e ; } , E x c l u s i o n : f u n c t i o n ( A , B ) { v a r   B = B | | { } ; B . f a i l u r e M e s s a g e = B . f a i l u r e M e s s a g e | | " 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 ! " ; B . 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 ( A , B ) ; r e t u r n   t r u e ; } , C o n f i r m a t i o n : f u n c t i o n ( C , D ) { i f ( ! D . 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   D = D | | { } ; v a r   B = D . f a i l u r e M e s s a g e | | " D o e s   n o t   m a t c h ! " ; v a r   A = D . m a t c h . n o d e N a m e ? D . 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 ( D . m a t c h ) ; i f ( ! A ) { 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   ' " + D . m a t c h + " ' ! " ) ; } i f ( C ! = A . v a l u e ) { V a l i d a t e . f a i l ( B ) ; } r e t u r n   t r u e ; } , A c c e p t a n c e : f u n c t i o n ( B , C ) { v a r   C = C | | { } ; v a r   A = C . 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 ( ! B ) { V a l i d a t e . f a i l ( A ) ; } r e t u r n   t r u e ; } , C u s t o m : f u n c t i o n ( D , E ) { v a r   E = E | | { } ; v a r   B = E . 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 = E . a r g s | | { } ; v a r   C = E . f a i l u r e M e s s a g e | | " N o t   v a l i d ! " ; i f ( ! B ( D , A ) ) { V a l i d a t e . f a i l ( C ) ; } r e t u r n   t r u e ; } , n o w : f u n c t i o n ( A , D , C ) { i f ( ! A ) { 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   E = t r u e ; t r y { A ( D , C | | { } ) ; } c a t c h ( B ) { i f ( B   i n s t a n c e o f   V a l i d a t e . E r r o r ) { E = f a l s e ; } e l s e { t h r o w   B ; } } f i n a l l y { r e t u r n   E ; } } , f a i l : f u n c t i o n ( A ) { t h r o w   n e w   V a l i d a t e . E r r o r ( A ) ; } , E r r o r : f u n c t i o n ( A ) { t h i s . m e s s a g e = A ; t h i s . n a m e = " V a l i d a t i o n E r r o r " ; } } ;  
 
