ÿþ/ /   F o r m C h e k . j s  
 / /  
 / /   S U M M A R Y  
 / /  
 / /   T h i s   i s   a   s e t   o f   J a v a S c r i p t   f u n c t i o n s   f o r   v a l i d a t i n g   i n p u t   o n    
 / /   a n   H T M L   f o r m .     F u n c t i o n s   a r e   p r o v i d e d   t o   v a l i d a t e :  
 / /  
 / /             -   U . S .   a n d   i n t e r n a t i o n a l   p h o n e / f a x   n u m b e r s  
 / /             -   U . S .   Z I P   c o d e s   ( 5   o r   9   d i g i t   p o s t a l   c o d e s )  
 / /             -   U . S .   P o s t a l   C o d e s   ( 2   l e t t e r   a b b r e v i a t i o n s   f o r   n a m e s   o f   s t a t e s )  
 / /             -   U . S .   S o c i a l   S e c u r i t y   N u m b e r s   ( a b b r e v i a t e d   a s   S S N s )  
 / /             -   e m a i l   a d d r e s s e s  
 / / 	 -   d a t e s   ( e n t r y   o f   y e a r ,   m o n t h ,   a n d   d a y   a n d   v a l i d i t y   o f   c o m b i n e d   d a t e )  
 / / 	 -   c r e d i t   c a r d   n u m b e r s  
 / /  
 / /   S u p p o r t i n g   u t i l i t y   f u n c t i o n s   v a l i d a t e   t h a t :  
 / /  
 / /             -   c h a r a c t e r s   a r e   L e t t e r ,   D i g i t ,   o r   L e t t e r O r D i g i t  
 / /             -   s t r i n g s   a r e   a   S i g n e d ,   P o s i t i v e ,   N e g a t i v e ,   N o n p o s i t i v e ,   o r  
 / /                 N o n n e g a t i v e   i n t e g e r  
 / /             -   s t r i n g s   a r e   a   F l o a t   o r   a   S i g n e d F l o a t  
 / /             -   s t r i n g s   a r e   A l p h a b e t i c ,   A l p h a n u m e r i c ,   o r   W h i t e s p a c e  
 / /             -   s t r i n g s   c o n t a i n   a n   i n t e g e r   w i t h i n   a   s p e c i f i e d   r a n g e  
 / /  
 / /   F u n c t i o n s   a r e   a l s o   p r o v i d e d   t o   i n t e r a c t i v e l y   c h e c k   t h e  
 / /   a b o v e   k i n d s   o f   d a t a   a n d   p r o m p t   t h e   u s e r   i f   t h e y   h a v e  
 / /   b e e n   e n t e r e d   i n c o r r e c t l y .  
 / /  
 / /   O t h e r   u t i l i t y   f u n c t i o n s   a r e   p r o v i d e d   t o :  
 / /  
 / /   	 -   r e m o v e   f r o m   a   s t r i n g   c h a r a c t e r s   w h i c h   a r e / a r e   n o t    
 / / 	     i n   a   " b a g "   o f   s e l e c t e d   c h a r a c t e r s 	  
 / /   	 -   r e f o r m a t   a   s t r i n g ,   a d d i n g   d e l i m i t e r   c h a r a c t e r s  
 / / 	 -   s t r i p   w h i t e s p a c e / l e a d i n g   w h i t e s p a c e   f r o m   a   s t r i n g  
 / /             -   r e f o r m a t   U . S .   p h o n e   n u m b e r s ,   Z I P   c o d e s ,   a n d   S o c i a l  
 / /                 S e c u r i t y   n u m b e r s  
 / /  
 / /  
 / /   M a n y   o f   t h e   b e l o w   f u n c t i o n s   t a k e   a n   o p t i o n a l   p a r a m e t e r   e o k   ( f o r   " e m p t y O K " )  
 / /   w h i c h   d e t e r m i n e s   w h e t h e r   t h e   e m p t y   s t r i n g   w i l l   r e t u r n   t r u e   o r   f a l s e .  
 / /   D e f a u l t   b e h a v i o r   i s   c o n t r o l l e d   b y   g l o b a l   v a r i a b l e   d e f a u l t E m p t y O K .  
 / /  
 / /   B A S I C   D A T A   V A L I D A T I O N   F U N C T I O N S :  
 / /  
 / /   i s W h i t e s p a c e   ( s )                                         C h e c k   w h e t h e r   s t r i n g   s   i s   e m p t y   o r   w h i t e s p a c e .  
 / /   i s L e t t e r   ( c )                                                 C h e c k   w h e t h e r   c h a r a c t e r   c   i s   a n   E n g l i s h   l e t t e r    
 / /   i s D i g i t   ( c )                                                   C h e c k   w h e t h e r   c h a r a c t e r   c   i s   a   d i g i t    
 / /   i s L e t t e r O r D i g i t   ( c )                                   C h e c k   w h e t h e r   c h a r a c t e r   c   i s   a   l e t t e r   o r   d i g i t .  
 / /   i s I n t e g e r   ( s   [ , e o k ] )                                 T r u e   i f   a l l   c h a r a c t e r s   i n   s t r i n g   s   a r e   n u m b e r s .  
 / /   i s S i g n e d I n t e g e r   ( s   [ , e o k ] )                     T r u e   i f   a l l   c h a r a c t e r s   i n   s t r i n g   s   a r e   n u m b e r s ;   l e a d i n g   +   o r   -   a l l o w e d .  
 / /   i s P o s i t i v e I n t e g e r   ( s   [ , e o k ] )                 T r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   >   0 .  
 / /   i s N o n n e g a t i v e I n t e g e r   ( s   [ , e o k ] )           T r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   > =   0 .  
 / /   i s N e g a t i v e I n t e g e r   ( s   [ , e o k ] )                 T r u e   i f   s   i s   a n   i n t e g e r   <   0 .  
 / /   i s N o n p o s i t i v e I n t e g e r   ( s   [ , e o k ] )           T r u e   i f   s   i s   a n   i n t e g e r   < =   0 .  
 / /   i s F l o a t   ( s   [ , e o k ] )                                     T r u e   i f   s t r i n g   s   i s   a n   u n s i g n e d   f l o a t i n g   p o i n t   ( r e a l )   n u m b e r .   ( I n t e g e r s   a l s o   O K . )  
 / /   i s S i g n e d F l o a t   ( s   [ , e o k ] )                         T r u e   i f   s t r i n g   s   i s   a   f l o a t i n g   p o i n t   n u m b e r ;   l e a d i n g   +   o r   -   a l l o w e d .   ( I n t e g e r s   a l s o   O K . )  
 / /   i s A l p h a b e t i c   ( s   [ , e o k ] )                           T r u e   i f   s t r i n g   s   i s   E n g l i s h   l e t t e r s    
 / /   i s A l p h a n u m e r i c   ( s   [ , e o k ] )                       T r u e   i f   s t r i n g   s   i s   E n g l i s h   l e t t e r s   a n d   n u m b e r s   o n l y .  
 / /    
 / /   i s S S N   ( s   [ , e o k ] )                                         T r u e   i f   s t r i n g   s   i s   a   v a l i d   U . S .   S o c i a l   S e c u r i t y   N u m b e r .  
 / /   i s U S P h o n e N u m b e r   ( s   [ , e o k ] )                     T r u e   i f   s t r i n g   s   i s   a   v a l i d   U . S .   P h o n e   N u m b e r .    
 / /   i s I n t e r n a t i o n a l P h o n e N u m b e r   ( s   [ , e o k ] )   T r u e   i f   s t r i n g   s   i s   a   v a l i d   i n t e r n a t i o n a l   p h o n e   n u m b e r .  
 / /   i s Z I P C o d e   ( s   [ , e o k ] )                                 T r u e   i f   s t r i n g   s   i s   a   v a l i d   U . S .   Z I P   c o d e .  
 / /   i s S t a t e C o d e   ( s   [ , e o k ] )                             T r u e   i f   s t r i n g   s   i s   a   v a l i d   U . S .   P o s t a l   C o d e  
 / /   i s E m a i l   ( s   [ , e o k ] )                                     T r u e   i f   s t r i n g   s   i s   a   v a l i d   e m a i l   a d d r e s s .  
 / /   i s Y e a r   ( s   [ , e o k ] )                                       T r u e   i f   s t r i n g   s   i s   a   v a l i d   Y e a r   n u m b e r .  
 / /   i s I n t e g e r I n R a n g e   ( s ,   a ,   b   [ , e o k ] )       T r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   b e t w e e n   a   a n d   b ,   i n c l u s i v e .  
 / /   i s M o n t h   ( s   [ , e o k ] )                                     T r u e   i f   s t r i n g   s   i s   a   v a l i d   m o n t h   b e t w e e n   1   a n d   1 2 .  
 / /   i s D a y   ( s   [ , e o k ] )                                         T r u e   i f   s t r i n g   s   i s   a   v a l i d   d a y   b e t w e e n   1   a n d   3 1 .  
 / /   d a y s I n F e b r u a r y   ( y e a r )                               R e t u r n s   n u m b e r   o f   d a y s   i n   F e b r u a r y   o f   t h a t   y e a r .  
 / /   i s D a t e   ( y e a r ,   m o n t h ,   d a y )                       T r u e   i f   s t r i n g   a r g u m e n t s   f o r m   a   v a l i d   d a t e .  
  
  
 / /   F U N C T I O N S   T O   R E F O R M A T   D A T A :  
 / /  
 / /   s t r i p C h a r s I n B a g   ( s ,   b a g )                         R e m o v e s   a l l   c h a r a c t e r s   i n   s t r i n g   b a g   f r o m   s t r i n g   s .  
 / /   s t r i p C h a r s N o t I n B a g   ( s ,   b a g )                   R e m o v e s   a l l   c h a r a c t e r s   N O T   i n   s t r i n g   b a g   f r o m   s t r i n g   s .  
 / /   s t r i p W h i t e s p a c e   ( s )                                   R e m o v e s   a l l   w h i t e s p a c e   c h a r a c t e r s   f r o m   s .  
 / /   s t r i p I n i t i a l W h i t e s p a c e   ( s )                     R e m o v e s   i n i t i a l   ( l e a d i n g )   w h i t e s p a c e   c h a r a c t e r s   f r o m   s .  
 / /   r e f o r m a t   ( T A R G E T S T R I N G ,   S T R I N G ,           F u n c t i o n   f o r   i n s e r t i n g   f o r m a t t i n g   c h a r a c t e r s   o r  
 / /       I N T E G E R ,   S T R I N G ,   I N T E G E R   . . .   )               d e l i m i t e r s   i n t o   T A R G E T S T R I N G .                                                                                
 / /   r e f o r m a t Z I P C o d e   ( Z I P S t r i n g )                   I f   9   d i g i t s ,   i n s e r t s   s e p a r a t o r   h y p h e n .  
 / /   r e f o r m a t S S N   ( S S N )                                       R e f o r m a t s   a s   1 2 3 - 4 5 - 6 7 8 9 .  
 / /   r e f o r m a t U S P h o n e   ( U S P h o n e )                       R e f o r m a t s   a s   ( 1 2 3 )   4 5 6 - 7 8 9 .  
  
  
 / /   F U N C T I O N S   T O   P R O M P T   U S E R :  
 / /  
 / /   p r o m p t   ( s )                                                     D i s p l a y   p r o m p t   s t r i n g   s   i n   s t a t u s   b a r .  
 / /   p r o m p t E n t r y   ( s )                                           D i s p l a y   d a t a   e n t r y   p r o m p t   s t r i n g   s   i n   s t a t u s   b a r .  
 / /   w a r n E m p t y   ( t h e F i e l d ,   s )                           N o t i f y   u s e r   t h a t   r e q u i r e d   f i e l d   t h e F i e l d   i s   e m p t y .  
 / /   w a r n I n v a l i d   ( t h e F i e l d ,   s )                       N o t i f y   u s e r   t h a t   c o n t e n t s   o f   f i e l d   t h e F i e l d   a r e   i n v a l i d .  
  
  
 / /   F U N C T I O N S   T O   I N T E R A C T I V E L Y   C H E C K   F I E L D   C O N T E N T S :  
 / /  
 / /   c h e c k S t r i n g   ( t h e F i e l d ,   s   [ , e o k ] )         C h e c k   t h a t   t h e F i e l d . v a l u e   i s   n o t   e m p t y   o r   a l l   w h i t e s p a c e .  
 / /   c h e c k S t a t e C o d e   ( t h e F i e l d )                       C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   U . S .   s t a t e   c o d e .  
 / /   c h e c k Z I P C o d e   ( t h e F i e l d   [ , e o k ] )             C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   Z I P   c o d e .  
 / /   c h e c k U S P h o n e   ( t h e F i e l d   [ , e o k ] )             C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   U S   P h o n e .  
 / /   c h e c k I n t e r n a t i o n a l P h o n e   ( t h e F i e l d   [ , e o k ] )     C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   I n t e r n a t i o n a l   P h o n e .  
 / /   c h e c k E m a i l   ( t h e F i e l d   [ , e o k ] )                 C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   E m a i l .  
 / /   c h e c k S S N   ( t h e F i e l d   [ , e o k ] )                     C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   S S N .  
 / /   c h e c k Y e a r   ( t h e F i e l d   [ , e o k ] )                   C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   Y e a r .  
 / /   c h e c k M o n t h   ( t h e F i e l d   [ , e o k ] )                 C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   M o n t h .  
 / /   c h e c k D a y   ( t h e F i e l d   [ , e o k ] )                     C h e c k   t h a t   t h e F i e l d . v a l u e   i s   a   v a l i d   D a y .  
 / /   c h e c k D a t e   ( y e a r F i e l d ,   m o n t h F i e l d ,   d a y F i e l d ,   l a b e l S t r i n g ,   O K t o O m i t D a y )  
 / /                                                                           C h e c k   t h a t   f i e l d   v a l u e s   f o r m   a   v a l i d   d a t e .  
 / /   g e t R a d i o B u t t o n V a l u e   ( r a d i o )                   G e t   c h e c k e d   v a l u e   f r o m   r a d i o   b u t t o n .  
 / /   c h e c k C r e d i t C a r d   ( r a d i o ,   t h e F i e l d )       V a l i d a t e   c r e d i t   c a r d   i n f o .  
  
  
 / /   C R E D I T   C A R D   D A T A   V A L I D A T I O N   F U N C T I O N S  
 / /    
 / /   i s C r e d i t C a r d   ( s t )                             T r u e   i f   c r e d i t   c a r d   n u m b e r   p a s s e s   t h e   L u h n   M o d - 1 0   t e s t .  
 / /   i s V i s a   ( c c )                                         T r u e   i f   s t r i n g   c c   i s   a   v a l i d   V I S A   n u m b e r .  
 / /   i s M a s t e r C a r d   ( c c )                             T r u e   i f   s t r i n g   c c   i s   a   v a l i d   M a s t e r C a r d   n u m b e r .  
 / /   i s A m e r i c a n E x p r e s s   ( c c )                   T r u e   i f   s t r i n g   c c   i s   a   v a l i d   A m e r i c a n   E x p r e s s   n u m b e r .  
 / /   i s D i n e r s C l u b   ( c c )                             T r u e   i f   s t r i n g   c c   i s   a   v a l i d   D i n e r ' s   C l u b   n u m b e r .  
 / /   i s C a r t e B l a n c h e   ( c c )                         T r u e   i f   s t r i n g   c c   i s   a   v a l i d   C a r t e   B l a n c h e   n u m b e r .  
 / /   i s D i s c o v e r   ( c c )                                 T r u e   i f   s t r i n g   c c   i s   a   v a l i d   D i s c o v e r   c a r d   n u m b e r .  
 / /   i s E n R o u t e   ( c c )                                   T r u e   i f   s t r i n g   c c   i s   a   v a l i d   e n R o u t e   c a r d   n u m b e r .  
 / /   i s J C B   ( c c )                                           T r u e   i f   s t r i n g   c c   i s   a   v a l i d   J C B   c a r d   n u m b e r .  
 / /   i s A n y C a r d   ( c c )                                   T r u e   i f   s t r i n g   c c   i s   a   v a l i d   c a r d   n u m b e r   f o r   a n y   o f   t h e   a c c e p t e d   t y p e s .  
 / /   i s C a r d M a t c h   ( T y p e ,   N u m b e r )           T r u e   i f   N u m b e r   i s   v a l i d   f o r   c r e d i c   c a r d   o f   t y p e   T y p e .  
 / /  
 / /   O t h e r   s t u b   f u n c t i o n s   a r e   r e t a i n e d   f o r   b a c k w a r d   c o m p a t i b i l i t y   w i t h   L i v e P a y m e n t   c o d e .  
 / /   S e e   c o m m e n t s   b e l o w   f o r   d e t a i l s .  
 / /  
 / /   P e r f o r m a n c e   h i n t :   w h e n   y o u   d e p l o y   t h i s   f i l e   o n   y o u r   w e b s i t e ,   s t r i p   o u t   t h e  
 / /   c o m m e n t   l i n e s   f r o m   t h e   s o u r c e   c o d e   a s   w e l l   a s   a n y   o f   t h e   f u n c t i o n s   w h i c h  
 / /   y o u   d o n ' t   n e e d .     T h i s   w i l l   g i v e   y o u   a   s m a l l e r   . j s   f i l e   a n d   a c h i e v e   f a s t e r  
 / /   d o w n l o a d s .  
 / /  
 / /   1 8   F e b   9 7   c r e a t e d   E r i c   K r o c k  
 / /  
 / /   ( c )   1 9 9 7   N e t s c a p e   C o m m u n i c a t i o n s   C o r p o r a t i o n  
  
  
  
 / /   V A R I A B L E   D E C L A R A T I O N S  
  
 v a r   d i g i t s   =   " 0 1 2 3 4 5 6 7 8 9 " ;  
  
 v a r   l o w e r c a s e L e t t e r s   =   " a b c d e f g h i j k l m n o p q r s t u v w x y z "  
  
 v a r   u p p e r c a s e L e t t e r s   =   " A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "  
  
  
 / /   w h i t e s p a c e   c h a r a c t e r s  
 v a r   w h i t e s p a c e   =   "   \ t \ n \ r " ;  
  
  
 / /   d e c i m a l   p o i n t   c h a r a c t e r   d i f f e r s   b y   l a n g u a g e   a n d   c u l t u r e  
 v a r   d e c i m a l P o i n t D e l i m i t e r   =   " . "  
  
  
 / /   n o n - d i g i t   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   p h o n e   n u m b e r s  
 v a r   p h o n e N u m b e r D e l i m i t e r s   =   " ( ) -   " ;  
  
  
 / /   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   U S   p h o n e   n u m b e r s  
 v a r   v a l i d U S P h o n e C h a r s   =   d i g i t s   +   p h o n e N u m b e r D e l i m i t e r s ;  
  
  
 / /   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   i n t e r n a t i o n a l   p h o n e   n u m b e r s  
 / /   ( a   l e a d i n g   +   i s   O K )  
 v a r   v a l i d W o r l d P h o n e C h a r s   =   d i g i t s   +   p h o n e N u m b e r D e l i m i t e r s   +   " + " ;  
  
  
 / /   n o n - d i g i t   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n    
 / /   S o c i a l   S e c u r i t y   N u m b e r s  
 v a r   S S N D e l i m i t e r s   =   " -   " ;  
  
  
  
 / /   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   S o c i a l   S e c u r i t y   N u m b e r s  
 v a r   v a l i d S S N C h a r s   =   d i g i t s   +   S S N D e l i m i t e r s ;  
  
  
  
 / /   U . S .   S o c i a l   S e c u r i t y   N u m b e r s   h a v e   9   d i g i t s .  
 / /   T h e y   a r e   f o r m a t t e d   a s   1 2 3 - 4 5 - 6 7 8 9 .  
 v a r   d i g i t s I n S o c i a l S e c u r i t y N u m b e r   =   9 ;  
  
  
  
 / /   U . S .   p h o n e   n u m b e r s   h a v e   1 0   d i g i t s .  
 / /   T h e y   a r e   f o r m a t t e d   a s   1 2 3   4 5 6   7 8 9 0   o r   ( 1 2 3 )   4 5 6 - 7 8 9 0 .  
 v a r   d i g i t s I n U S P h o n e N u m b e r   =   1 0 ;  
  
  
  
 / /   n o n - d i g i t   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   Z I P   C o d e s  
 v a r   Z I P C o d e D e l i m i t e r s   =   " - " ;  
  
  
  
 / /   o u r   p r e f e r r e d   d e l i m i t e r   f o r   r e f o r m a t t i n g   Z I P   C o d e s  
 v a r   Z I P C o d e D e l i m e t e r   =   " - "  
  
  
 / /   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   S o c i a l   S e c u r i t y   N u m b e r s  
 v a r   v a l i d Z I P C o d e C h a r s   =   d i g i t s   +   Z I P C o d e D e l i m i t e r s  
  
  
  
 / /   U . S .   Z I P   c o d e s   h a v e   5   o r   9   d i g i t s .  
 / /   T h e y   a r e   f o r m a t t e d   a s   1 2 3 4 5   o r   1 2 3 4 5 - 6 7 8 9 .  
 v a r   d i g i t s I n Z I P C o d e 1   =   5  
 v a r   d i g i t s I n Z I P C o d e 2   =   9  
  
  
 / /   n o n - d i g i t   c h a r a c t e r s   w h i c h   a r e   a l l o w e d   i n   c r e d i t   c a r d   n u m b e r s  
 v a r   c r e d i t C a r d D e l i m i t e r s   =   "   "  
  
  
 / /   C O N S T A N T   S T R I N G   D E C L A R A T I O N S  
 / /   ( g r o u p e d   f o r   e a s e   o f   t r a n s l a t i o n   a n d   l o c a l i z a t i o n )  
  
 / /   m   i s   a n   a b b r e v i a t i o n   f o r   " m i s s i n g "  
  
 v a r   m P r e f i x   =   " Y o u   d i d   n o t   e n t e r   a   v a l u e   i n t o   t h e   "  
 v a r   m S u f f i x   =   "   f i e l d .   T h i s   i s   a   r e q u i r e d   f i e l d .   P l e a s e   e n t e r   i t   n o w . "  
  
 / /   s   i s   a n   a b b r e v i a t i o n   f o r   " s t r i n g "  
  
 v a r   s U S L a s t N a m e   =   " L a s t   N a m e "  
 v a r   s U S F i r s t N a m e   =   " F i r s t   N a m e "  
 v a r   s W o r l d L a s t N a m e   =   " F a m i l y   N a m e "  
 v a r   s W o r l d F i r s t N a m e   =   " G i v e n   N a m e "  
 v a r   s T i t l e   =   " T i t l e "  
 v a r   s C o m p a n y N a m e   =   " C o m p a n y   N a m e "  
 v a r   s U S A d d r e s s   =   " S t r e e t   A d d r e s s "  
 v a r   s W o r l d A d d r e s s   =   " A d d r e s s "  
 v a r   s C i t y   =   " C i t y "  
 v a r   s S t a t e C o d e   =   " S t a t e   C o d e "  
 v a r   s W o r l d S t a t e   =   " S t a t e ,   P r o v i n c e ,   o r   P r e f e c t u r e "  
 v a r   s C o u n t r y   =   " C o u n t r y "  
 v a r   s Z I P C o d e   =   " Z I P   C o d e "  
 v a r   s W o r l d P o s t a l C o d e   =   " P o s t a l   C o d e "  
 v a r   s P h o n e   =   " P h o n e   N u m b e r "  
 v a r   s F a x   =   " F a x   N u m b e r "  
 v a r   s D a t e O f B i r t h   =   " D a t e   o f   B i r t h "  
 v a r   s E x p i r a t i o n D a t e   =   " E x p i r a t i o n   D a t e "  
 v a r   s E m a i l   =   " E m a i l "  
 v a r   s S S N   =   " S o c i a l   S e c u r i t y   N u m b e r "  
 v a r   s C r e d i t C a r d N u m b e r   =   " C r e d i t   C a r d   N u m b e r "  
 v a r   s O t h e r I n f o   =   " O t h e r   I n f o r m a t i o n "  
 v a r   s N a t i o n a l C o d e =   " N a t i o n a l   C o d e "   / /   ©/EDÌ 
  
  
  
 / /   i   i s   a n   a b b r e v i a t i o n   f o r   " i n v a l i d "  
  
 v a r   i S t a t e C o d e   =   " T h i s   f i e l d   m u s t   b e   a   v a l i d   t w o   c h a r a c t e r   U . S .   s t a t e   a b b r e v i a t i o n   ( l i k e   C A   f o r   C a l i f o r n i a ) .   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i Z I P C o d e   =   " T h i s   f i e l d   m u s t   b e   a   5   o r   9   d i g i t   U . S .   Z I P   C o d e   ( l i k e   9 4 0 4 3 ) .   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i U S P h o n e   =   " T h i s   f i e l d   m u s t   b e   a   1 0   d i g i t   U . S .   p h o n e   n u m b e r   ( l i k e   4 1 5   5 5 5   1 2 1 2 ) .   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i W o r l d P h o n e   =   " T h i s   f i e l d   m u s t   b e   a   v a l i d   i n t e r n a t i o n a l   p h o n e   n u m b e r .   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i S S N   =   " T h i s   f i e l d   m u s t   b e   a   9   d i g i t   U . S .   s o c i a l   s e c u r i t y   n u m b e r   ( l i k e   1 2 3   4 5   6 7 8 9 ) .   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i E m a i l   =   " T h i s   f i e l d   m u s t   b e   a   v a l i d   e m a i l   a d d r e s s   ( l i k e   f o o @ b a r . c o m ) .   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i C r e d i t C a r d P r e f i x   =   " T h i s   i s   n o t   a   v a l i d   "  
 v a r   i C r e d i t C a r d S u f f i x   =   "   c r e d i t   c a r d   n u m b e r .   ( C l i c k   t h e   l i n k   o n   t h i s   f o r m   t o   s e e   a   l i s t   o f   s a m p l e   n u m b e r s . )   P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i D a y   =   " T h i s   f i e l d   m u s t   b e   a   d a y   n u m b e r   b e t w e e n   1   a n d   3 1 .     P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i M o n t h   =   " T h i s   f i e l d   m u s t   b e   a   m o n t h   n u m b e r   b e t w e e n   1   a n d   1 2 .     P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i Y e a r   =   " T h i s   f i e l d   m u s t   b e   a   2   o r   4   d i g i t   y e a r   n u m b e r .     P l e a s e   r e e n t e r   i t   n o w . "  
 v a r   i D a t e P r e f i x   =   " T h e   D a y ,   M o n t h ,   a n d   Y e a r   f o r   "  
 v a r   i D a t e S u f f i x   =   "   d o   n o t   f o r m   a   v a l i d   d a t e .     P l e a s e   r e e n t e r   t h e m   n o w . "  
  
  
  
 / /   p   i s   a n   a b b r e v i a t i o n   f o r   " p r o m p t "  
  
 v a r   p E n t r y P r o m p t   =   " P l e a s e   e n t e r   a   "  
 v a r   p S t a t e C o d e   =   " 2   c h a r a c t e r   c o d e   ( l i k e   C A ) . "  
 v a r   p Z I P C o d e   =   " 5   o r   9   d i g i t   U . S .   Z I P   C o d e   ( l i k e   9 4 0 4 3 ) . "  
 v a r   p U S P h o n e   =   " 1 0   d i g i t   U . S .   p h o n e   n u m b e r   ( l i k e   4 1 5   5 5 5   1 2 1 2 ) . "  
 v a r   p W o r l d P h o n e   =   " i n t e r n a t i o n a l   p h o n e   n u m b e r . "  
 v a r   p S S N   =   " 9   d i g i t   U . S .   s o c i a l   s e c u r i t y   n u m b e r   ( l i k e   1 2 3   4 5   6 7 8 9 ) . "  
 v a r   p E m a i l   =   " v a l i d   e m a i l   a d d r e s s   ( l i k e   f o o @ b a r . c o m ) . "  
 v a r   p C r e d i t C a r d   =   " v a l i d   c r e d i t   c a r d   n u m b e r . "  
 v a r   p D a y   =   " d a y   n u m b e r   b e t w e e n   1   a n d   3 1 . "  
 v a r   p M o n t h   =   " m o n t h   n u m b e r   b e t w e e n   1   a n d   1 2 . "  
 v a r   p Y e a r   =   " 2   o r   4   d i g i t   y e a r   n u m b e r . "  
 v a r   S h a m s d a y s I n M o n t h   =   m a k e A r r a y ( 1 2 ) ;  
 S h a m s d a y s I n M o n t h [ 1 ]     =   3 1 ;  
 S h a m s d a y s I n M o n t h [ 2 ]     =   3 1 ;       / /   m u s t   p r o g r a m m a t i c a l l y   c h e c k   t h i s  
 S h a m s d a y s I n M o n t h [ 3 ]     =   3 1 ;  
 S h a m s d a y s I n M o n t h [ 4 ]     =   3 1 ;  
 S h a m s d a y s I n M o n t h [ 5 ]     =   3 1 ;  
 S h a m s d a y s I n M o n t h [ 6 ]     =   3 1 ;  
 S h a m s d a y s I n M o n t h [ 7 ]     =   3 0 ;  
 S h a m s d a y s I n M o n t h [ 8 ]     =   3 0 ;  
 S h a m s d a y s I n M o n t h [ 9 ]     =   3 0 ;  
 S h a m s d a y s I n M o n t h [ 1 0 ]   =   3 0 ;  
 S h a m s d a y s I n M o n t h [ 1 1 ]   =   3 0 ;  
 S h a m s d a y s I n M o n t h [ 1 2 ]   =   3 0 ;  
 v a r   d a y s I n M o n t h   =   m a k e A r r a y ( 1 2 ) ;  
 d a y s I n M o n t h [ 1 ]   =   3 1 ;  
 d a y s I n M o n t h [ 2 ]   =   2 9 ;       / /   m u s t   p r o g r a m m a t i c a l l y   c h e c k   t h i s  
 d a y s I n M o n t h [ 3 ]   =   3 1 ;  
 d a y s I n M o n t h [ 4 ]   =   3 0 ;  
 d a y s I n M o n t h [ 5 ]   =   3 1 ;  
 d a y s I n M o n t h [ 6 ]   =   3 0 ;  
 d a y s I n M o n t h [ 7 ]   =   3 1 ;  
 d a y s I n M o n t h [ 8 ]   =   3 1 ;  
 d a y s I n M o n t h [ 9 ]   =   3 0 ;  
 d a y s I n M o n t h [ 1 0 ]   =   3 1 ;  
 d a y s I n M o n t h [ 1 1 ]   =   3 0 ;  
 d a y s I n M o n t h [ 1 2 ]   =   3 1 ;  
  
 / /   G l o b a l   v a r i a b l e   d e f a u l t E m p t y O K   d e f i n e s   d e f a u l t   r e t u r n   v a l u e    
 / /   f o r   m a n y   f u n c t i o n s   w h e n   t h e y   a r e   p a s s e d   t h e   e m p t y   s t r i n g .    
 / /   B y   d e f a u l t ,   t h e y   w i l l   r e t u r n   d e f a u l t E m p t y O K .  
 / /  
 / /   d e f a u l t E m p t y O K   i s   f a l s e ,   w h i c h   m e a n s   t h a t   b y   d e f a u l t ,    
 / /   t h e s e   f u n c t i o n s   w i l l   d o   " s t r i c t "   v a l i d a t i o n .     F u n c t i o n  
 / /   i s I n t e g e r ,   f o r   e x a m p l e ,   w i l l   o n l y   r e t u r n   t r u e   i f   i t   i s  
 / /   p a s s e d   a   s t r i n g   c o n t a i n i n g   a n   i n t e g e r ;   i f   i t   i s   p a s s e d  
 / /   t h e   e m p t y   s t r i n g ,   i t   w i l l   r e t u r n   f a l s e .  
 / /  
 / /   Y o u   c a n   c h a n g e   t h i s   d e f a u l t   b e h a v i o r   g l o b a l l y   ( f o r   a l l    
 / /   f u n c t i o n s   w h i c h   u s e   d e f a u l t E m p t y O K )   b y   c h a n g i n g   t h e   v a l u e  
 / /   o f   d e f a u l t E m p t y O K .  
 / /  
 / /   M o s t   o f   t h e s e   f u n c t i o n s   h a v e   a n   o p t i o n a l   a r g u m e n t   e m p t y O K  
 / /   w h i c h   a l l o w s   y o u   t o   o v e r r i d e   t h e   d e f a u l t   b e h a v i o r   f o r    
 / /   t h e   d u r a t i o n   o f   a   f u n c t i o n   c a l l .  
 / /  
 / /   T h i s   f u n c t i o n a l i t y   i s   u s e f u l   b e c a u s e   i t   i s   p o s s i b l e   t o  
 / /   s a y   " i f   t h e   u s e r   p u t s   a n y t h i n g   i n   t h i s   f i e l d ,   i t   m u s t  
 / /   b e   a n   i n t e g e r   ( o r   a   p h o n e   n u m b e r ,   o r   a   s t r i n g ,   e t c . ) ,    
 / /   b u t   i t ' s   O K   t o   l e a v e   t h e   f i e l d   e m p t y   t o o . "  
 / /   T h i s   i s   t h e   c a s e   f o r   f i e l d s   w h i c h   a r e   o p t i o n a l   b u t   w h i c h  
 / /   m u s t   h a v e   a   c e r t a i n   k i n d   o f   c o n t e n t   i f   f i l l e d   i n .  
  
 v a r   d e f a u l t E m p t y O K   =   f a l s e  
  
  
  
  
 / /   A t t e m p t i n g   t o   m a k e   t h i s   l i b r a r y   r u n   o n   N a v i g a t o r   2 . 0 ,  
 / /   s o   I ' m   s u p p l y i n g   t h i s   a r r a y   c r e a t i o n   r o u t i n e   a s   p e r  
 / /   J a v a S c r i p t   1 . 0   d o c u m e n t a t i o n .     I f   y o u ' r e   u s i n g    
 / /   N a v i g a t o r   3 . 0   o r   l a t e r ,   y o u   d o n ' t   n e e d   t o   d o   t h i s ;  
 / /   y o u   c a n   u s e   t h e   A r r a y   c o n s t r u c t o r   i n s t e a d .  
  
 f u n c t i o n   m a k e A r r a y ( n )   {  
 / / * * *   B U G :   I f   I   p u t   t h i s   l i n e   i n ,   I   g e t   t w o   e r r o r   m e s s a g e s :  
 / / ( 1 )   W i n d o w . l e n g t h   c a n ' t   b e   s e t   b y   a s s i g n m e n t  
 / / ( 2 )   d a y s I n M o n t h   h a s   n o   p r o p e r t y   i n d e x e d   b y   4  
 / / I f   I   l e a v e   i t   o u t ,   t h e   c o d e   w o r k s   f i n e .  
 / /       t h i s . l e n g t h   =   n ;  
       f o r   ( v a r   i   =   1 ;   i   < =   n ;   i + + )   {  
             t h i s [ i ]   =   0  
       }    
       r e t u r n   t h i s  
 }  
  
  
  
 v a r   d a y s I n M o n t h   =   m a k e A r r a y ( 1 2 ) ;  
 d a y s I n M o n t h [ 1 ]   =   3 1 ;  
 d a y s I n M o n t h [ 2 ]   =   2 9 ;       / /   m u s t   p r o g r a m m a t i c a l l y   c h e c k   t h i s  
 d a y s I n M o n t h [ 3 ]   =   3 1 ;  
 d a y s I n M o n t h [ 4 ]   =   3 0 ;  
 d a y s I n M o n t h [ 5 ]   =   3 1 ;  
 d a y s I n M o n t h [ 6 ]   =   3 0 ;  
 d a y s I n M o n t h [ 7 ]   =   3 1 ;  
 d a y s I n M o n t h [ 8 ]   =   3 1 ;  
 d a y s I n M o n t h [ 9 ]   =   3 0 ;  
 d a y s I n M o n t h [ 1 0 ]   =   3 1 ;  
 d a y s I n M o n t h [ 1 1 ]   =   3 0 ;  
 d a y s I n M o n t h [ 1 2 ]   =   3 1 ;  
  
  
  
  
 / /   V a l i d   U . S .   P o s t a l   C o d e s   f o r   s t a t e s ,   t e r r i t o r i e s ,   a r m e d   f o r c e s ,   e t c .  
 / /   S e e   h t t p : / / w w w . u s p s . g o v / n c s c / l o o k u p s / a b b r _ s t a t e . t x t .  
  
 v a r   U S S t a t e C o d e D e l i m i t e r   =   " | " ;  
 v a r   U S S t a t e C o d e s   =   " A L | A K | A S | A Z | A R | C A | C O | C T | D E | D C | F M | F L | G A | G U | H I | I D | I L | I N | I A | K S | K Y | L A | M E | M H | M D | M A | M I | M N | M S | M O | M T | N E | N V | N H | N J | N M | N Y | N C | N D | M P | O H | O K | O R | P W | P A | P R | R I | S C | S D | T N | T X | U T | V T | V I | V A | W A | W V | W I | W Y | A E | A A | A E | A E | A P "  
  
  
  
  
 / /   C h e c k   w h e t h e r   s t r i n g   s   i s   e m p t y .  
  
 f u n c t i o n   i s E m p t y ( s )  
 {       r e t u r n   ( ( s   = =   n u l l )   | |   ( s . l e n g t h   = =   0 ) )  
 }  
  
  
  
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   e m p t y   o r    
 / /   w h i t e s p a c e   c h a r a c t e r s   o n l y .  
  
 f u n c t i o n   i s W h i t e s p a c e   ( s )  
  
 {       v a r   i ;  
  
         / /   I s   s   e m p t y ?  
         i f   ( i s E m p t y ( s ) )   r e t u r n   t r u e ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e  
         / /   u n t i l   w e   f i n d   a   n o n - w h i t e s p a c e   c h a r a c t e r .  
         / /   W h e n   w e   d o ,   r e t u r n   f a l s e ;   i f   w e   d o n ' t ,   r e t u r n   t r u e .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s n ' t   w h i t e s p a c e .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
  
                 i f   ( w h i t e s p a c e . i n d e x O f ( c )   = =   - 1 )   r e t u r n   f a l s e ;  
         }  
  
         / /   A l l   c h a r a c t e r s   a r e   w h i t e s p a c e .  
         r e t u r n   t r u e ;  
 }  
  
  
  
 / /   R e m o v e s   a l l   c h a r a c t e r s   w h i c h   a p p e a r   i n   s t r i n g   b a g   f r o m   s t r i n g   s .  
  
 f u n c t i o n   s t r i p C h a r s I n B a g   ( s ,   b a g )  
  
 {       v a r   i ;  
         v a r   r e t u r n S t r i n g   =   " " ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e .  
         / /   I f   c h a r a c t e r   i s   n o t   i n   b a g ,   a p p e n d   t o   r e t u r n S t r i n g .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s n ' t   w h i t e s p a c e .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
                 i f   ( b a g . i n d e x O f ( c )   = =   - 1 )   r e t u r n S t r i n g   + =   c ;  
         }  
  
         r e t u r n   r e t u r n S t r i n g ;  
 }  
  
  
  
 / /   R e m o v e s   a l l   c h a r a c t e r s   w h i c h   d o   N O T   a p p e a r   i n   s t r i n g   b a g    
 / /   f r o m   s t r i n g   s .  
  
 f u n c t i o n   s t r i p C h a r s N o t I n B a g   ( s ,   b a g )  
  
 {       v a r   i ;  
         v a r   r e t u r n S t r i n g   =   " " ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e .  
         / /   I f   c h a r a c t e r   i s   i n   b a g ,   a p p e n d   t o   r e t u r n S t r i n g .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s n ' t   w h i t e s p a c e .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
                 i f   ( b a g . i n d e x O f ( c )   ! =   - 1 )   r e t u r n S t r i n g   + =   c ;  
         }  
  
         r e t u r n   r e t u r n S t r i n g ;  
 }  
  
  
  
 / /   R e m o v e s   a l l   w h i t e s p a c e   c h a r a c t e r s   f r o m   s .  
 / /   G l o b a l   v a r i a b l e   w h i t e s p a c e   ( s e e   a b o v e )  
 / /   d e f i n e s   w h i c h   c h a r a c t e r s   a r e   c o n s i d e r e d   w h i t e s p a c e .  
  
 f u n c t i o n   s t r i p W h i t e s p a c e   ( s )  
  
 {       r e t u r n   s t r i p C h a r s I n B a g   ( s ,   w h i t e s p a c e )  
 }  
  
  
  
  
 / /   W O R K A R O U N D   F U N C T I O N   F O R   N A V I G A T O R   2 . 0 . 2   C O M P A T I B I L I T Y .  
 / /  
 / /   T h e   b e l o w   f u n c t i o n   * s h o u l d *   b e   u n n e c e s s a r y .     I n   g e n e r a l ,  
 / /   a v o i d   u s i n g   i t .     U s e   t h e   s t a n d a r d   m e t h o d   i n d e x O f   i n s t e a d .  
 / /  
 / /   H o w e v e r ,   b e c a u s e   o f   a n   a p p a r e n t   b u g   i n   i n d e x O f   o n    
 / /   N a v i g a t o r   2 . 0 . 2 ,   t h e   b e l o w   l o o p   d o e s   n o t   w o r k   a s   t h e  
 / /   b o d y   o f   s t r i p I n i t i a l W h i t e s p a c e :  
 / /  
 / /   w h i l e   ( ( i   <   s . l e n g t h )   & &   ( w h i t e s p a c e . i n d e x O f ( s . c h a r A t ( i ) )   ! =   - 1 ) )  
 / /       i + + ;  
 / /  
 / /   . . .   s o   w e   p r o v i d e   t h i s   w o r k a r o u n d   f u n c t i o n   c h a r I n S t r i n g  
 / /   i n s t e a d .  
 / /  
 / /   c h a r I n S t r i n g   ( C H A R A C T E R   c ,   S T R I N G   s )  
 / /  
 / /   R e t u r n s   t r u e   i f   s i n g l e   c h a r a c t e r   c   ( a c t u a l l y   a   s t r i n g )  
 / /   i s   c o n t a i n e d   w i t h i n   s t r i n g   s .  
  
 f u n c t i o n   c h a r I n S t r i n g   ( c ,   s )  
 {       f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {       i f   ( s . c h a r A t ( i )   = =   c )   r e t u r n   t r u e ;  
         }  
         r e t u r n   f a l s e  
 }  
  
  
  
 / /   R e m o v e s   i n i t i a l   ( l e a d i n g )   w h i t e s p a c e   c h a r a c t e r s   f r o m   s .  
 / /   G l o b a l   v a r i a b l e   w h i t e s p a c e   ( s e e   a b o v e )  
 / /   d e f i n e s   w h i c h   c h a r a c t e r s   a r e   c o n s i d e r e d   w h i t e s p a c e .  
  
 f u n c t i o n   s t r i p I n i t i a l W h i t e s p a c e   ( s )  
  
 {       v a r   i   =   0 ;  
  
         w h i l e   ( ( i   <   s . l e n g t h )   & &   c h a r I n S t r i n g   ( s . c h a r A t ( i ) ,   w h i t e s p a c e ) )  
               i + + ;  
          
         r e t u r n   s . s u b s t r i n g   ( i ,   s . l e n g t h ) ;  
 }  
  
  
  
  
  
  
  
 / /   R e t u r n s   t r u e   i f   c h a r a c t e r   c   i s   a n   E n g l i s h   l e t t e r    
 / /   ( A   . .   Z ,   a . . z ) .  
 / /  
 / /   N O T E :   N e e d   i 1 8 n   v e r s i o n   t o   s u p p o r t   E u r o p e a n   c h a r a c t e r s .  
 / /   T h i s   c o u l d   b e   t r i c k y   d u e   t o   d i f f e r e n t   c h a r a c t e r  
 / /   s e t s   a n d   o r d e r i n g s   f o r   v a r i o u s   l a n g u a g e s   a n d   p l a t f o r m s .  
  
 f u n c t i o n   i s L e t t e r   ( c )  
 {       r e t u r n   (   ( ( c   > =   " a " )   & &   ( c   < =   " z " ) )   | |   ( ( c   > =   " A " )   & &   ( c   < =   " Z " ) )   | |   ( c = " _ " )   )  
 }  
  
  
  
 / /   R e t u r n s   t r u e   i f   c h a r a c t e r   c   i s   a   d i g i t    
 / /   ( 0   . .   9 ) .  
  
 f u n c t i o n   i s D i g i t   ( c )  
 {       r e t u r n   ( ( c   > =   " 0 " )   & &   ( c   < =   " 9 " ) )  
 }  
  
  
  
 / /   R e t u r n s   t r u e   i f   c h a r a c t e r   c   i s   a   l e t t e r   o r   d i g i t .  
  
 f u n c t i o n   i s L e t t e r O r D i g i t   ( c )  
 {       r e t u r n   ( i s L e t t e r ( c )   | |   i s D i g i t ( c ) )  
 }  
  
  
  
 / /   i s I n t e g e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   a l l   c h a r a c t e r s   i n   s t r i n g   s   a r e   n u m b e r s .  
 / /  
 / /   A c c e p t s   n o n - s i g n e d   i n t e g e r s   o n l y .   D o e s   n o t   a c c e p t   f l o a t i n g    
 / /   p o i n t ,   e x p o n e n t i a l   n o t a t i o n ,   e t c .  
 / /  
 / /   W e   d o n ' t   u s e   p a r s e I n t   b e c a u s e   t h a t   w o u l d   a c c e p t   a   s t r i n g  
 / /   w i t h   t r a i l i n g   n o n - n u m e r i c   c h a r a c t e r s .  
 / /  
 / /   B y   d e f a u l t ,   r e t u r n s   d e f a u l t E m p t y O K   i f   s   i s   e m p t y .  
 / /   T h e r e   i s   a n   o p t i o n a l   s e c o n d   a r g u m e n t   c a l l e d   e m p t y O K .  
 / /   e m p t y O K   i s   u s e d   t o   o v e r r i d e   f o r   a   s i n g l e   f u n c t i o n   c a l l  
 / /             t h e   d e f a u l t   b e h a v i o r   w h i c h   i s   s p e c i f i e d   g l o b a l l y   b y  
 / /             d e f a u l t E m p t y O K .  
 / /   I f   e m p t y O K   i s   f a l s e   ( o r   a n y   v a l u e   o t h e r   t h a n   t r u e ) ,    
 / /             t h e   f u n c t i o n   w i l l   r e t u r n   f a l s e   i f   s   i s   e m p t y .  
 / /   I f   e m p t y O K   i s   t r u e ,   t h e   f u n c t i o n   w i l l   r e t u r n   t r u e   i f   s   i s   e m p t y .  
 / /  
 / /   E X A M P L E   F U N C T I O N   C A L L :           R E S U L T :  
 / /   i s I n t e g e r   ( " 5 " )                         t r u e    
 / /   i s I n t e g e r   ( " " )                           d e f a u l t E m p t y O K  
 / /   i s I n t e g e r   ( " - 5 " )                       f a l s e  
 / /   i s I n t e g e r   ( " " ,   t r u e )               t r u e  
 / /   i s I n t e g e r   ( " " ,   f a l s e )             f a l s e  
 / /   i s I n t e g e r   ( " 5 " ,   f a l s e )           t r u e  
  
 f u n c t i o n   i s I n t e g e r   ( s )  
  
 {       v a r   i ;  
  
         i f   ( i s E m p t y ( s ) )    
               i f   ( i s I n t e g e r . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s I n t e g e r . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e  
         / /   u n t i l   w e   f i n d   a   n o n - n u m e r i c   c h a r a c t e r .  
         / /   W h e n   w e   d o ,   r e t u r n   f a l s e ;   i f   w e   d o n ' t ,   r e t u r n   t r u e .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s   n u m b e r .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
  
                 i f   ( ! i s D i g i t ( c ) )   r e t u r n   f a l s e ;  
         }  
  
         / /   A l l   c h a r a c t e r s   a r e   n u m b e r s .  
         r e t u r n   t r u e ;  
 }  
  
 / /   A d d e d   b y   M a h d i   G h e r e k h l o o   8 9 - 0 8 - 3 0  
 / /   †©  ©1/F  5-*  ©/  EDÌ   
 f u n c t i o n   i s N a t i o n a l C o d e   ( s )  
 {  
  
       v a r   i ;  
       / /   t r u e   .'DÌ  (H/F  1'  †©  EÌ  ©F/ 
                   i f ( i s N a t i o n a l C o d e . a r g u m e n t s [ 1 ]   = =   t r u e   )  
                         i f   ( s   = =   ' ' )   r e t u r n   t r u e   ;  
                   i f   ( i s N a t i o n a l C o d e . a r g u m e n t s [ 1 ]   = =   f a l s e )  
                         i f   ( i s E m p t y ( s )   | |   s   = =   ' ' )   r e t u r n   f a l s e   ;  
                                
                  
                 i f   ( s . l e n g t h   ! =   1 0   )   r e t u r n   f a l s e   ;  
                  
                 f o r   ( i   =   0 ;   i   <   1 0 ;   i + + )  
                 {        
                         v a r   c   =   s . c h a r A t ( i ) ;  
  
                         i f   ( ! i s D i g i t ( c ) )   r e t u r n   f a l s e ;  
                 }  
                  
         r e t u r n   t r u e ;  
 }  
  
 f u n c t i o n   d a y s I n E s f a n d   ( y e a r )  
 {       / /   e s f a n d   h a s   2 9   d a y s   i n   a n y   y e a r + 1   e v e n l y   d i v i s i b l e   b y   f o u r ,  
         / /   E X C E P T   f o r   c e n t u r i a l   y e a r s   w h i c h   a r e   n o t   a l s o   d i v i s i b l e   b y   4 0 0 .  
         r e t u r n   (   ( ( ( y e a r + 1 )   %   4   = =   0 )   & &   (   ( ! ( ( y e a r + 1 )   %   1 0 0   = =   0 ) )   | |   ( ( y e a r + 1 )   %   4 0 0   = =   0 )   )   )   ?   3 0   :   2 9   ) ;  
 }  
  
 f u n c t i o n   i s S h a m s D a t e   ( y e a r ,   m o n t h ,   d a y )  
 {       / /   c a t c h   i n v a l i d   y e a r s   ( n o t   2 -   o r   4 - d i g i t )   a n d   i n v a l i d   m o n t h s   a n d   d a y s .  
         i f   ( !   ( i s Y e a r ( y e a r ,   f a l s e )   & &   i s M o n t h ( m o n t h ,   f a l s e )   & &   i s D a y ( d a y ,   f a l s e ) ) )   r e t u r n   f a l s e ;  
  
         / /   E x p l i c i t l y   c h a n g e   t y p e   t o   i n t e g e r   t o   m a k e   c o d e   w o r k   i n   b o t h  
         / /   J a v a S c r i p t   1 . 1   a n d   J a v a S c r i p t   1 . 2 .  
         v a r   i n t Y e a r     =   p a r s e I n t ( y e a r ) ;  
         v a r   i n t M o n t h   =   p a r s e I n t ( m o n t h ) ;  
         / / a l e r t ( d a y ) ;  
         v a r   i n t D a y       =   p a r s e I n t ( d a y ) ;  
         / / a l e r t ( i n t D a y ) ;  
  
         / /   c a t c h   i n v a l i d   d a y s ,   e x c e p t   f o r   F e b r u a r y  
         i f   ( i n t D a y   >   S h a m s d a y s I n M o n t h [ i n t M o n t h ] )   r e t u r n   f a l s e ;    
  
         i f   ( ( i n t M o n t h   = =   1 2 )   & &   ( i n t D a y   >   d a y s I n E s f a n d ( i n t Y e a r ) ) )   r e t u r n   f a l s e ;  
  
         r e t u r n   t r u e ;  
 }  
  
 f u n c t i o n   i s Y e a r   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s Y e a r . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s Y e a r . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         i f   ( ! i s N o n n e g a t i v e I n t e g e r ( s ) )   r e t u r n   f a l s e ;  
         r e t u r n   ( ( s . l e n g t h   = =   2 )   | |   ( s . l e n g t h   = =   4 ) ) ;  
 }  
  
 f u n c t i o n   i s D a t e   ( y e a r ,   m o n t h ,   d a y )  
 {       / /   c a t c h   i n v a l i d   y e a r s   ( n o t   2 -   o r   4 - d i g i t )   a n d   i n v a l i d   m o n t h s   a n d   d a y s .  
         i f   ( !   ( i s Y e a r ( y e a r ,   f a l s e )   & &   i s M o n t h ( m o n t h ,   f a l s e )   & &   i s D a y ( d a y ,   f a l s e ) ) )   r e t u r n   f a l s e ;  
  
         / /   E x p l i c i t l y   c h a n g e   t y p e   t o   i n t e g e r   t o   m a k e   c o d e   w o r k   i n   b o t h  
         / /   J a v a S c r i p t   1 . 1   a n d   J a v a S c r i p t   1 . 2 .  
         v a r   i n t Y e a r   =   p a r s e I n t ( y e a r ) ;  
         v a r   i n t M o n t h   =   p a r s e I n t ( m o n t h ) ;  
         v a r   i n t D a y   =   p a r s e I n t ( d a y ) ;  
  
         / /   c a t c h   i n v a l i d   d a y s ,   e x c e p t   f o r   F e b r u a r y  
         i f   ( i n t D a y   >   d a y s I n M o n t h [ i n t M o n t h ] )   r e t u r n   f a l s e ;    
  
         i f   ( ( i n t M o n t h   = =   2 )   & &   ( i n t D a y   >   d a y s I n F e b r u a r y ( i n t Y e a r ) ) )   r e t u r n   f a l s e ;  
  
         r e t u r n   t r u e ;  
 }  
  
 f u n c t i o n   i s M o n t h   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s M o n t h . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s M o n t h . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         r e t u r n   i s I n t e g e r I n R a n g e   ( s ,   1 ,   1 2 ) ;  
 }  
  
  
 / /   i s S i g n e d I n t e g e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   a l l   c h a r a c t e r s   a r e   n u m b e r s ;    
 / /   f i r s t   c h a r a c t e r   i s   a l l o w e d   t o   b e   +   o r   -   a s   w e l l .  
 / /  
 / /   D o e s   n o t   a c c e p t   f l o a t i n g   p o i n t ,   e x p o n e n t i a l   n o t a t i o n ,   e t c .  
 / /  
 / /   W e   d o n ' t   u s e   p a r s e I n t   b e c a u s e   t h a t   w o u l d   a c c e p t   a   s t r i n g  
 / /   w i t h   t r a i l i n g   n o n - n u m e r i c   c h a r a c t e r s .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
 / /  
 / /   E X A M P L E   F U N C T I O N   C A L L :                     R E S U L T :  
 / /   i s S i g n e d I n t e g e r   ( " 5 " )                       t r u e    
 / /   i s S i g n e d I n t e g e r   ( " " )                         d e f a u l t E m p t y O K  
 / /   i s S i g n e d I n t e g e r   ( " - 5 " )                     t r u e  
 / /   i s S i g n e d I n t e g e r   ( " + 5 " )                     t r u e  
 / /   i s S i g n e d I n t e g e r   ( " " ,   f a l s e )           f a l s e  
 / /   i s S i g n e d I n t e g e r   ( " " ,   t r u e )             t r u e  
  
 f u n c t i o n   i s S i g n e d I n t e g e r   ( s )  
  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s S i g n e d I n t e g e r . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s S i g n e d I n t e g e r . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         e l s e   {  
                 v a r   s t a r t P o s   =   0 ;  
                 v a r   s e c o n d A r g   =   d e f a u l t E m p t y O K ;  
  
                 i f   ( i s S i g n e d I n t e g e r . a r g u m e n t s . l e n g t h   >   1 )  
                         s e c o n d A r g   =   i s S i g n e d I n t e g e r . a r g u m e n t s [ 1 ] ;  
  
                 / /   s k i p   l e a d i n g   +   o r   -  
                 i f   (   ( s . c h a r A t ( 0 )   = =   " - " )   | |   ( s . c h a r A t ( 0 )   = =   " + " )   )  
                       s t a r t P o s   =   1 ;          
                 r e t u r n   ( i s I n t e g e r ( s . s u b s t r i n g ( s t a r t P o s ,   s . l e n g t h ) ,   s e c o n d A r g ) )  
         }  
 }  
  
  
 f u n c t i o n   c m p D a t e ( d 1 _ y e a r ,   d 1 _ m o n t h ,   d 1 _ d a y ,   d 2 _ y e a r ,   d 2 _ m o n t h ,   d 2 _ d a y )  
 {  
 	 i f   ( d 1 _ m o n t h . l e n g t h   = =   1 )  
 	 	 d 1 _ m o n t h   =   ' 0 '   +   d 1 _ m o n t h ;  
 	 i f   ( d 1 _ d a y . l e n g t h   = =   1 )  
 	 	 d 1 _ d a y   =   ' 0 '   +   d 1 _ d a y ;  
 	 i f   ( d 2 _ m o n t h . l e n g t h   = =   1 )  
 	 	 d 2 _ m o n t h   =   ' 0 '   +   d 2 _ m o n t h ;  
 	 i f   ( d 2 _ d a y . l e n g t h   = =   1 )  
 	 	 d 2 _ d a y   =   ' 0 '   +   d 2 _ d a y ;  
 	 v a r   d 1   =   p a r s e I n t ( d 1 _ y e a r   +     d 1 _ m o n t h   +   d 1 _ d a y ) ;  
 	 v a r   d 2   =   p a r s e I n t ( d 2 _ y e a r   +     d 2 _ m o n t h   +   d 2 _ d a y ) ;  
 	 i f   ( d 1   >   d 2 )  
 	 	 r e t u r n   1 ;  
 	 i f   ( d 1   <   d 2 )  
 	 	 r e t u r n   - 1 ;  
 	 r e t u r n   0 ;   / /   i s   e q u a l  
 }  
  
  
 / /   i s P o s i t i v e I n t e g e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   >   0 .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s P o s i t i v e I n t e g e r   ( s )  
 {       v a r   s e c o n d A r g   =   d e f a u l t E m p t y O K ;  
  
         i f   ( i s P o s i t i v e I n t e g e r . a r g u m e n t s . l e n g t h   >   1 )  
                 s e c o n d A r g   =   i s P o s i t i v e I n t e g e r . a r g u m e n t s [ 1 ] ;  
  
         / /   T h e   n e x t   l i n e   i s   a   b i t   b y z a n t i n e .     W h a t   i t   m e a n s   i s :  
         / /   a )   s   m u s t   b e   a   s i g n e d   i n t e g e r ,   A N D  
         / /   b )   o n e   o f   t h e   f o l l o w i n g   m u s t   b e   t r u e :  
         / /         i )     s   i s   e m p t y   a n d   w e   a r e   s u p p o s e d   t o   r e t u r n   t r u e   f o r  
         / /                 e m p t y   s t r i n g s  
         / /         i i )   t h i s   i s   a   p o s i t i v e ,   n o t   n e g a t i v e ,   n u m b e r  
  
         r e t u r n   ( i s S i g n e d I n t e g e r ( s ,   s e c o n d A r g )  
                   & &   (   ( i s E m p t y ( s )   & &   s e c o n d A r g )     | |   ( p a r s e I n t   ( s )   >   0 )   )   ) ;  
 }  
  
  
  
  
  
  
 / /   i s N o n n e g a t i v e I n t e g e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   > =   0 .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s N o n n e g a t i v e I n t e g e r   ( s )  
 {       v a r   s e c o n d A r g   =   d e f a u l t E m p t y O K ;  
  
         i f   ( i s N o n n e g a t i v e I n t e g e r . a r g u m e n t s . l e n g t h   >   1 )  
                 s e c o n d A r g   =   i s N o n n e g a t i v e I n t e g e r . a r g u m e n t s [ 1 ] ;  
  
         / /   T h e   n e x t   l i n e   i s   a   b i t   b y z a n t i n e .     W h a t   i t   m e a n s   i s :  
         / /   a )   s   m u s t   b e   a   s i g n e d   i n t e g e r ,   A N D  
         / /   b )   o n e   o f   t h e   f o l l o w i n g   m u s t   b e   t r u e :  
         / /         i )     s   i s   e m p t y   a n d   w e   a r e   s u p p o s e d   t o   r e t u r n   t r u e   f o r  
         / /                 e m p t y   s t r i n g s  
         / /         i i )   t h i s   i s   a   n u m b e r   > =   0  
  
         r e t u r n   ( i s S i g n e d I n t e g e r ( s ,   s e c o n d A r g )  
                   & &   (   ( i s E m p t y ( s )   & &   s e c o n d A r g )     | |   ( p a r s e I n t   ( s )   > =   0 )   )   ) ;  
 }  
  
  
  
  
  
  
 / /   i s N e g a t i v e I n t e g e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   <   0 .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s N e g a t i v e I n t e g e r   ( s )  
 {       v a r   s e c o n d A r g   =   d e f a u l t E m p t y O K ;  
  
         i f   ( i s N e g a t i v e I n t e g e r . a r g u m e n t s . l e n g t h   >   1 )  
                 s e c o n d A r g   =   i s N e g a t i v e I n t e g e r . a r g u m e n t s [ 1 ] ;  
  
         / /   T h e   n e x t   l i n e   i s   a   b i t   b y z a n t i n e .     W h a t   i t   m e a n s   i s :  
         / /   a )   s   m u s t   b e   a   s i g n e d   i n t e g e r ,   A N D  
         / /   b )   o n e   o f   t h e   f o l l o w i n g   m u s t   b e   t r u e :  
         / /         i )     s   i s   e m p t y   a n d   w e   a r e   s u p p o s e d   t o   r e t u r n   t r u e   f o r  
         / /                 e m p t y   s t r i n g s  
         / /         i i )   t h i s   i s   a   n e g a t i v e ,   n o t   p o s i t i v e ,   n u m b e r  
  
         r e t u r n   ( i s S i g n e d I n t e g e r ( s ,   s e c o n d A r g )  
                   & &   (   ( i s E m p t y ( s )   & &   s e c o n d A r g )     | |   ( p a r s e I n t   ( s )   <   0 )   )   ) ;  
 }  
  
  
  
  
  
  
 / /   i s N o n p o s i t i v e I n t e g e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   a n   i n t e g e r   < =   0 .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s N o n p o s i t i v e I n t e g e r   ( s )  
 {       v a r   s e c o n d A r g   =   d e f a u l t E m p t y O K ;  
  
         i f   ( i s N o n p o s i t i v e I n t e g e r . a r g u m e n t s . l e n g t h   >   1 )  
                 s e c o n d A r g   =   i s N o n p o s i t i v e I n t e g e r . a r g u m e n t s [ 1 ] ;  
  
         / /   T h e   n e x t   l i n e   i s   a   b i t   b y z a n t i n e .     W h a t   i t   m e a n s   i s :  
         / /   a )   s   m u s t   b e   a   s i g n e d   i n t e g e r ,   A N D  
         / /   b )   o n e   o f   t h e   f o l l o w i n g   m u s t   b e   t r u e :  
         / /         i )     s   i s   e m p t y   a n d   w e   a r e   s u p p o s e d   t o   r e t u r n   t r u e   f o r  
         / /                 e m p t y   s t r i n g s  
         / /         i i )   t h i s   i s   a   n u m b e r   < =   0  
  
         r e t u r n   ( i s S i g n e d I n t e g e r ( s ,   s e c o n d A r g )  
                   & &   (   ( i s E m p t y ( s )   & &   s e c o n d A r g )     | |   ( p a r s e I n t   ( s )   < =   0 )   )   ) ;  
 }  
  
  
  
  
  
 / /   i s F l o a t   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   T r u e   i f   s t r i n g   s   i s   a n   u n s i g n e d   f l o a t i n g   p o i n t   ( r e a l )   n u m b e r .    
 / /  
 / /   A l s o   r e t u r n s   t r u e   f o r   u n s i g n e d   i n t e g e r s .   I f   y o u   w i s h  
 / /   t o   d i s t i n g u i s h   b e t w e e n   i n t e g e r s   a n d   f l o a t i n g   p o i n t   n u m b e r s ,  
 / /   f i r s t   c a l l   i s I n t e g e r ,   t h e n   c a l l   i s F l o a t .  
 / /  
 / /   D o e s   n o t   a c c e p t   e x p o n e n t i a l   n o t a t i o n .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s F l o a t   ( s )  
  
 {       v a r   i ;  
         v a r   s e e n D e c i m a l P o i n t   =   f a l s e ;  
  
         i f   ( i s E m p t y ( s ) )    
               i f   ( i s F l o a t . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s F l o a t . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         i f   ( s   = =   d e c i m a l P o i n t D e l i m i t e r )   r e t u r n   f a l s e ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e  
         / /   u n t i l   w e   f i n d   a   n o n - n u m e r i c   c h a r a c t e r .  
         / /   W h e n   w e   d o ,   r e t u r n   f a l s e ;   i f   w e   d o n ' t ,   r e t u r n   t r u e .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s   n u m b e r .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
  
                 i f   ( ( c   = =   d e c i m a l P o i n t D e l i m i t e r )   & &   ! s e e n D e c i m a l P o i n t )   s e e n D e c i m a l P o i n t   =   t r u e ;  
                 e l s e   i f   ( ! i s D i g i t ( c ) )   r e t u r n   f a l s e ;  
         }  
  
         / /   A l l   c h a r a c t e r s   a r e   n u m b e r s .  
         r e t u r n   t r u e ;  
 }  
  
  
  
  
  
  
  
 / /   i s S i g n e d F l o a t   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   T r u e   i f   s t r i n g   s   i s   a   s i g n e d   o r   u n s i g n e d   f l o a t i n g   p o i n t    
 / /   ( r e a l )   n u m b e r .   F i r s t   c h a r a c t e r   i s   a l l o w e d   t o   b e   +   o r   - .  
 / /  
 / /   A l s o   r e t u r n s   t r u e   f o r   u n s i g n e d   i n t e g e r s .   I f   y o u   w i s h  
 / /   t o   d i s t i n g u i s h   b e t w e e n   i n t e g e r s   a n d   f l o a t i n g   p o i n t   n u m b e r s ,  
 / /   f i r s t   c a l l   i s S i g n e d I n t e g e r ,   t h e n   c a l l   i s S i g n e d F l o a t .  
 / /  
 / /   D o e s   n o t   a c c e p t   e x p o n e n t i a l   n o t a t i o n .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s S i g n e d F l o a t   ( s )  
  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s S i g n e d F l o a t . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s S i g n e d F l o a t . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         e l s e   {  
                 v a r   s t a r t P o s   =   0 ;  
                 v a r   s e c o n d A r g   =   d e f a u l t E m p t y O K ;  
  
                 i f   ( i s S i g n e d F l o a t . a r g u m e n t s . l e n g t h   >   1 )  
                         s e c o n d A r g   =   i s S i g n e d F l o a t . a r g u m e n t s [ 1 ] ;  
  
                 / /   s k i p   l e a d i n g   +   o r   -  
                 i f   (   ( s . c h a r A t ( 0 )   = =   " - " )   | |   ( s . c h a r A t ( 0 )   = =   " + " )   )  
                       s t a r t P o s   =   1 ;          
                 r e t u r n   ( i s F l o a t ( s . s u b s t r i n g ( s t a r t P o s ,   s . l e n g t h ) ,   s e c o n d A r g ) )  
         }  
 }  
  
  
  
  
 / /   i s A l p h a b e t i c   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   E n g l i s h   l e t t e r s    
 / /   ( A   . .   Z ,   a . . z )   o n l y .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
 / /  
 / /   N O T E :   N e e d   i 1 8 n   v e r s i o n   t o   s u p p o r t   E u r o p e a n   c h a r a c t e r s .  
 / /   T h i s   c o u l d   b e   t r i c k y   d u e   t o   d i f f e r e n t   c h a r a c t e r  
 / /   s e t s   a n d   o r d e r i n g s   f o r   v a r i o u s   l a n g u a g e s   a n d   p l a t f o r m s .  
  
 f u n c t i o n   i s A l p h a b e t i c   ( s )  
  
 {       v a r   i ;  
  
         i f   ( i s E m p t y ( s ) )    
               i f   ( i s A l p h a b e t i c . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s A l p h a b e t i c . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e  
         / /   u n t i l   w e   f i n d   a   n o n - a l p h a b e t i c   c h a r a c t e r .  
         / /   W h e n   w e   d o ,   r e t u r n   f a l s e ;   i f   w e   d o n ' t ,   r e t u r n   t r u e .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s   l e t t e r .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
  
                 i f   ( ! i s L e t t e r ( c ) )  
                 r e t u r n   f a l s e ;  
         }  
  
         / /   A l l   c h a r a c t e r s   a r e   l e t t e r s .  
         r e t u r n   t r u e ;  
 }  
  
  
  
  
 / /   i s A l p h a n u m e r i c   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n s   t r u e   i f   s t r i n g   s   i s   E n g l i s h   l e t t e r s    
 / /   ( A   . .   Z ,   a . . z )   a n d   n u m b e r s   o n l y .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
 / /  
 / /   N O T E :   N e e d   i 1 8 n   v e r s i o n   t o   s u p p o r t   E u r o p e a n   c h a r a c t e r s .  
 / /   T h i s   c o u l d   b e   t r i c k y   d u e   t o   d i f f e r e n t   c h a r a c t e r  
 / /   s e t s   a n d   o r d e r i n g s   f o r   v a r i o u s   l a n g u a g e s   a n d   p l a t f o r m s .  
  
 f u n c t i o n   i s A l p h a n u m e r i c   ( s )  
  
 {       v a r   i ;  
  
         i f   ( i s E m p t y ( s ) )    
               i f   ( i s A l p h a n u m e r i c . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s A l p h a n u m e r i c . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         / /   S e a r c h   t h r o u g h   s t r i n g ' s   c h a r a c t e r s   o n e   b y   o n e  
         / /   u n t i l   w e   f i n d   a   n o n - a l p h a n u m e r i c   c h a r a c t e r .  
         / /   W h e n   w e   d o ,   r e t u r n   f a l s e ;   i f   w e   d o n ' t ,   r e t u r n   t r u e .  
  
         f o r   ( i   =   0 ;   i   <   s . l e n g t h ;   i + + )  
         {        
                 / /   C h e c k   t h a t   c u r r e n t   c h a r a c t e r   i s   n u m b e r   o r   l e t t e r .  
                 v a r   c   =   s . c h a r A t ( i ) ;  
  
                 i f   ( !   ( i s L e t t e r ( c )   | |   i s D i g i t ( c )   )   )  
                 r e t u r n   f a l s e ;  
         }  
  
         / /   A l l   c h a r a c t e r s   a r e   n u m b e r s   o r   l e t t e r s .  
         r e t u r n   t r u e ;  
 }  
  
  
  
  
 / /   r e f o r m a t   ( T A R G E T S T R I N G ,   S T R I N G ,   I N T E G E R ,   S T R I N G ,   I N T E G E R   . . .   )                
 / /  
 / /   H a n d y   f u n c t i o n   f o r   a r b i t r a r i l y   i n s e r t i n g   f o r m a t t i n g   c h a r a c t e r s  
 / /   o r   d e l i m i t e r s   o f   v a r i o u s   k i n d s   w i t h i n   T A R G E T S T R I N G .  
 / /  
 / /   r e f o r m a t   t a k e s   o n e   n a m e d   a r g u m e n t ,   a   s t r i n g   s ,   a n d   a n y   n u m b e r  
 / /   o f   o t h e r   a r g u m e n t s .     T h e   o t h e r   a r g u m e n t s   m u s t   b e   i n t e g e r s   o r  
 / /   s t r i n g s .     T h e s e   o t h e r   a r g u m e n t s   s p e c i f y   h o w   s t r i n g   s   i s   t o   b e  
 / /   r e f o r m a t t e d   a n d   h o w   a n d   w h e r e   o t h e r   s t r i n g s   a r e   t o   b e   i n s e r t e d  
 / /   i n t o   i t .  
 / /  
 / /   r e f o r m a t   p r o c e s s e s   t h e   o t h e r   a r g u m e n t s   i n   o r d e r   o n e   b y   o n e .  
 / /   *   I f   t h e   a r g u m e n t   i s   a n   i n t e g e r ,   r e f o r m a t   a p p e n d s   t h a t   n u m b e r    
 / /       o f   s e q u e n t i a l   c h a r a c t e r s   f r o m   s   t o   t h e   r e s u l t S t r i n g .  
 / /   *   I f   t h e   a r g u m e n t   i s   a   s t r i n g ,   r e f o r m a t   a p p e n d s   t h e   s t r i n g  
 / /       t o   t h e   r e s u l t S t r i n g .  
 / /  
 / /   N O T E :   T h e   f i r s t   a r g u m e n t   a f t e r   T A R G E T S T R I N G   m u s t   b e   a   s t r i n g .  
 / /   ( I t   c a n   b e   e m p t y . )     T h e   s e c o n d   a r g u m e n t   m u s t   b e   a n   i n t e g e r .  
 / /   T h e r e a f t e r ,   i n t e g e r s   a n d   s t r i n g s   m u s t   a l t e r n a t e .     T h i s   i s   t o  
 / /   p r o v i d e   b a c k w a r d   c o m p a t i b i l i t y   t o   N a v i g a t o r   2 . 0 . 2   J a v a S c r i p t  
 / /   b y   a v o i d i n g   u s e   o f   t h e   t y p e o f   o p e r a t o r .  
 / /  
 / /   I t   i s   t h e   c a l l e r ' s   r e s p o n s i b i l i t y   t o   m a k e   s u r e   t h a t   w e   d o   n o t  
 / /   t r y   t o   c o p y   m o r e   c h a r a c t e r s   f r o m   s   t h a n   s . l e n g t h .  
 / /  
 / /   E X A M P L E S :  
 / /  
 / /   *   T o   r e f o r m a t   a   1 0 - d i g i t   U . S .   p h o n e   n u m b e r   f r o m   " 1 2 3 4 5 6 7 8 9 0 "  
 / /       t o   " ( 1 2 3 )   4 5 6 - 7 8 9 0 "   m a k e   t h i s   f u n c t i o n   c a l l :  
 / /       r e f o r m a t ( " 1 2 3 4 5 6 7 8 9 0 " ,   " ( " ,   3 ,   " )   " ,   3 ,   " - " ,   4 )  
 / /  
 / /   *   T o   r e f o r m a t   a   9 - d i g i t   U . S .   S o c i a l   S e c u r i t y   n u m b e r   f r o m  
 / /       " 1 2 3 4 5 6 7 8 9 "   t o   " 1 2 3 - 4 5 - 6 7 8 9 "   m a k e   t h i s   f u n c t i o n   c a l l :  
 / /       r e f o r m a t ( " 1 2 3 4 5 6 7 8 9 " ,   " " ,   3 ,   " - " ,   2 ,   " - " ,   4 )  
 / /  
 / /   H I N T :  
 / /  
 / /   I f   y o u   h a v e   a   s t r i n g   w h i c h   i s   a l r e a d y   d e l i m i t e d   i n   o n e   w a y  
 / /   ( e x a m p l e :   a   p h o n e   n u m b e r   d e l i m i t e d   w i t h   s p a c e s   a s   " 1 2 3   4 5 6   7 8 9 0 " )  
 / /   a n d   y o u   w a n t   t o   d e l i m i t   i t   i n   a n o t h e r   w a y   u s i n g   f u n c t i o n   r e f o r m a t ,  
 / /   c a l l   f u n c t i o n   s t r i p C h a r s N o t I n B a g   t o   r e m o v e   t h e   u n w a n t e d    
 / /   c h a r a c t e r s ,   T H E N   c a l l   f u n c t i o n   r e f o r m a t   t o   d e l i m i t   a s   d e s i r e d .  
 / /  
 / /   E X A M P L E :  
 / /  
 / /   r e f o r m a t   ( s t r i p C h a r s N o t I n B a g   ( " 1 2 3   4 5 6   7 8 9 0 " ,   d i g i t s ) ,  
 / /                       " ( " ,   3 ,   " )   " ,   3 ,   " - " ,   4 )  
  
 f u n c t i o n   r e f o r m a t   ( s )  
  
 {       v a r   a r g ;  
         v a r   s P o s   =   0 ;  
         v a r   r e s u l t S t r i n g   =   " " ;  
  
         f o r   ( v a r   i   =   1 ;   i   <   r e f o r m a t . a r g u m e n t s . l e n g t h ;   i + + )   {  
               a r g   =   r e f o r m a t . a r g u m e n t s [ i ] ;  
               i f   ( i   %   2   = =   1 )   r e s u l t S t r i n g   + =   a r g ;  
               e l s e   {  
                       r e s u l t S t r i n g   + =   s . s u b s t r i n g ( s P o s ,   s P o s   +   a r g ) ;  
                       s P o s   + =   a r g ;  
               }  
         }  
         r e t u r n   r e s u l t S t r i n g ;  
 }  
  
  
  
  
 / /   i s S S N   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s S S N   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d   U . S .   S o c i a l  
 / /   S e c u r i t y   N u m b e r .     M u s t   b e   9   d i g i t s .  
 / /  
 / /   N O T E :   S t r i p   o u t   a n y   d e l i m i t e r s   ( s p a c e s ,   h y p h e n s ,   e t c . )  
 / /   f r o m   s t r i n g   s   b e f o r e   c a l l i n g   t h i s   f u n c t i o n .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s S S N   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s S S N . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s S S N . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         r e t u r n   ( i s I n t e g e r ( s )   & &   s . l e n g t h   = =   d i g i t s I n S o c i a l S e c u r i t y N u m b e r )  
 }  
  
  
  
  
 / /   i s U S P h o n e N u m b e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s U S P h o n e N u m b e r   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d   U . S .   P h o n e  
 / /   N u m b e r .     M u s t   b e   1 0   d i g i t s .  
 / /  
 / /   N O T E :   S t r i p   o u t   a n y   d e l i m i t e r s   ( s p a c e s ,   h y p h e n s ,   p a r e n t h e s e s ,   e t c . )  
 / /   f r o m   s t r i n g   s   b e f o r e   c a l l i n g   t h i s   f u n c t i o n .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s U S P h o n e N u m b e r   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s U S P h o n e N u m b e r . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s U S P h o n e N u m b e r . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         r e t u r n   ( i s I n t e g e r ( s )   & &   s . l e n g t h   = =   d i g i t s I n U S P h o n e N u m b e r )  
 }  
  
  
  
  
 / /   i s I n t e r n a t i o n a l P h o n e N u m b e r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s I n t e r n a t i o n a l P h o n e N u m b e r   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d    
 / /   i n t e r n a t i o n a l   p h o n e   n u m b e r .     M u s t   b e   d i g i t s   o n l y ;   a n y   l e n g t h   O K .  
 / /   M a y   b e   p r e f i x e d   b y   +   c h a r a c t e r .  
 / /  
 / /   N O T E :   A   p h o n e   n u m b e r   o f   a l l   z e r o s   w o u l d   n o t   b e   a c c e p t e d .  
 / /   I   d o n ' t   t h i n k   t h a t   i s   a   v a l i d   p h o n e   n u m b e r   a n y w a y .  
 / /  
 / /   N O T E :   S t r i p   o u t   a n y   d e l i m i t e r s   ( s p a c e s ,   h y p h e n s ,   p a r e n t h e s e s ,   e t c . )  
 / /   f r o m   s t r i n g   s   b e f o r e   c a l l i n g   t h i s   f u n c t i o n .     Y o u   m a y   l e a v e   i n    
 / /   l e a d i n g   +   c h a r a c t e r   i f   y o u   w i s h .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s I n t e r n a t i o n a l P h o n e N u m b e r   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s I n t e r n a t i o n a l P h o n e N u m b e r . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s I n t e r n a t i o n a l P h o n e N u m b e r . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         r e t u r n   ( i s P o s i t i v e I n t e g e r ( s ) )  
 }  
  
  
  
  
 / /   i s Z I P C o d e   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s Z I P C o d e   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d    
 / /   U . S .   Z I P   c o d e .     M u s t   b e   5   o r   9   d i g i t s   o n l y .  
 / /  
 / /   N O T E :   S t r i p   o u t   a n y   d e l i m i t e r s   ( s p a c e s ,   h y p h e n s ,   e t c . )  
 / /   f r o m   s t r i n g   s   b e f o r e   c a l l i n g   t h i s   f u n c t i o n .      
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s Z I P C o d e   ( s )  
 {     i f   ( i s E m p t y ( s ) )    
               i f   ( i s Z I P C o d e . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s Z I P C o d e . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
       r e t u r n   ( i s I n t e g e r ( s )   & &    
                         ( ( s . l e n g t h   = =   d i g i t s I n Z I P C o d e 1 )   | |  
                           ( s . l e n g t h   = =   d i g i t s I n Z I P C o d e 2 ) ) )  
 }  
  
  
  
  
  
 / /   i s S t a t e C o d e   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   R e t u r n   t r u e   i f   s   i s   a   v a l i d   U . S .   P o s t a l   C o d e    
 / /   ( a b b r e v i a t i o n   f o r   s t a t e ) .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s S t a t e C o d e ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s S t a t e C o d e . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s S t a t e C o d e . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         r e t u r n   (   ( U S S t a t e C o d e s . i n d e x O f ( s )   ! =   - 1 )   & &  
                           ( s . i n d e x O f ( U S S t a t e C o d e D e l i m i t e r )   = =   - 1 )   )  
 }  
  
  
  
  
 / /   i s E m a i l   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   E m a i l   a d d r e s s   m u s t   b e   o f   f o r m   a @ b . c   - -   i n   o t h e r   w o r d s :  
 / /   *   t h e r e   m u s t   b e   a t   l e a s t   o n e   c h a r a c t e r   b e f o r e   t h e   @  
 / /   *   t h e r e   m u s t   b e   a t   l e a s t   o n e   c h a r a c t e r   b e f o r e   a n d   a f t e r   t h e   .  
 / /   *   t h e   c h a r a c t e r s   @   a n d   .   a r e   b o t h   r e q u i r e d  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s E m a i l   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s E m a i l . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s E m a i l . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
        
         / /   i s   s   w h i t e s p a c e ?  
         i f   ( i s W h i t e s p a c e ( s ) )   r e t u r n   f a l s e ;  
          
         / /   t h e r e   m u s t   b e   > =   1   c h a r a c t e r   b e f o r e   @ ,   s o   w e  
         / /   s t a r t   l o o k i n g   a t   c h a r a c t e r   p o s i t i o n   1    
         / /   ( i . e .   s e c o n d   c h a r a c t e r )  
         v a r   i   =   1 ;  
         v a r   s L e n g t h   =   s . l e n g t h ;  
  
         / /   l o o k   f o r   @  
         w h i l e   ( ( i   <   s L e n g t h )   & &   ( s . c h a r A t ( i )   ! =   " @ " ) )  
         {   i + +  
         }  
  
         i f   ( ( i   > =   s L e n g t h )   | |   ( s . c h a r A t ( i )   ! =   " @ " ) )   r e t u r n   f a l s e ;  
         e l s e   i   + =   2 ;  
  
         / /   l o o k   f o r   .  
         w h i l e   ( ( i   <   s L e n g t h )   & &   ( s . c h a r A t ( i )   ! =   " . " ) )  
         {   i + +  
         }  
  
         / /   t h e r e   m u s t   b e   a t   l e a s t   o n e   c h a r a c t e r   a f t e r   t h e   .  
         i f   ( ( i   > =   s L e n g t h   -   1 )   | |   ( s . c h a r A t ( i )   ! =   " . " ) )   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 ;  
 }  
  
  
  
  
  
 / /   i s Y e a r   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s Y e a r   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d    
 / /   Y e a r   n u m b e r .     M u s t   b e   2   o r   4   d i g i t s   o n l y .  
 / /    
 / /   F o r   Y e a r   2 0 0 0   c o m p l i a n c e ,   y o u   a r e   a d v i s e d  
 / /   t o   u s e   4 - d i g i t   y e a r   n u m b e r s   e v e r y w h e r e .  
 / /  
 / /   A n d   y e s ,   t h i s   f u n c t i o n   i s   n o t   Y e a r   1 0 0 0 0   c o m p l i a n t ,   b u t    
 / /   b e c a u s e   I   a m   g i v i n g   y o u   8 0 0 3   y e a r s   o f   a d v a n c e   n o t i c e ,  
 / /   I   d o n ' t   f e e l   v e r y   g u i l t y   a b o u t   t h i s   . . .  
 / /  
 / /   F o r   B . C .   c o m p l i a n c e ,   w r i t e   y o u r   o w n   f u n c t i o n .   ; - >  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s Y e a r   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s Y e a r . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s Y e a r . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         i f   ( ! i s N o n n e g a t i v e I n t e g e r ( s ) )   r e t u r n   f a l s e ;  
         r e t u r n   ( ( s . l e n g t h   = =   2 )   | |   ( s . l e n g t h   = =   4 ) ) ;  
 }  
  
  
  
 / /   i s I n t e g e r I n R a n g e   ( S T R I N G   s ,   I N T E G E R   a ,   I N T E G E R   b   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s I n t e g e r I n R a n g e   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a n   i n t e g e r    
 / /   w i t h i n   t h e   r a n g e   o f   i n t e g e r   a r g u m e n t s   a   a n d   b ,   i n c l u s i v e .  
 / /    
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
  
 f u n c t i o n   i s I n t e g e r I n R a n g e   ( s ,   a ,   b )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s I n t e g e r I n R a n g e . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s I n t e g e r I n R a n g e . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
  
         / /   C a t c h   n o n - i n t e g e r   s t r i n g s   t o   a v o i d   c r e a t i n g   a   N a N   b e l o w ,  
         / /   w h i c h   i s n ' t   a v a i l a b l e   o n   J a v a S c r i p t   1 . 0   f o r   W i n d o w s .  
         i f   ( ! i s I n t e g e r ( s ,   f a l s e ) )   r e t u r n   f a l s e ;  
  
         / /   N o w ,   e x p l i c i t l y   c h a n g e   t h e   t y p e   t o   i n t e g e r   v i a   p a r s e I n t  
         / /   s o   t h a t   t h e   c o m p a r i s o n   c o d e   b e l o w   w i l l   w o r k   b o t h   o n    
         / /   J a v a S c r i p t   1 . 2   ( w h i c h   t y p e c h e c k s   i n   e q u a l i t y   c o m p a r i s o n s )  
         / /   a n d   J a v a S c r i p t   1 . 1   a n d   b e f o r e   ( w h i c h   d o e s n ' t ) .  
         v a r   n u m   =   p a r s e I n t   ( s ) ;  
         r e t u r n   ( ( n u m   > =   a )   & &   ( n u m   < =   b ) ) ;  
 }  
  
  
  
 / /   i s M o n t h   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s M o n t h   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d    
 / /   m o n t h   n u m b e r   b e t w e e n   1   a n d   1 2 .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s M o n t h   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s M o n t h . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s M o n t h . a r g u m e n t s [ 1 ]   = =   t r u e ) ;  
         r e t u r n   i s I n t e g e r I n R a n g e   ( s ,   1 ,   1 2 ) ;  
 }  
  
  
  
  
 / /   i s D a y   ( S T R I N G   s   [ ,   B O O L E A N   e m p t y O K ] )  
 / /    
 / /   i s D a y   r e t u r n s   t r u e   i f   s t r i n g   s   i s   a   v a l i d    
 / /   d a y   n u m b e r   b e t w e e n   1   a n d   3 1 .  
 / /    
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   i s D a y   ( s )  
 {       i f   ( i s E m p t y ( s ) )    
               i f   ( i s D a y . a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   d e f a u l t E m p t y O K ;  
               e l s e   r e t u r n   ( i s D a y . a r g u m e n t s [ 1 ]   = =   t r u e ) ;        
         r e t u r n   i s I n t e g e r I n R a n g e   ( s ,   1 ,   3 1 ) ;  
 }  
  
  
  
 / /   d a y s I n F e b r u a r y   ( I N T E G E R   y e a r )  
 / /    
 / /   G i v e n   i n t e g e r   a r g u m e n t   y e a r ,  
 / /   r e t u r n s   n u m b e r   o f   d a y s   i n   F e b r u a r y   o f   t h a t   y e a r .  
  
 f u n c t i o n   d a y s I n F e b r u a r y   ( y e a r )  
 {       / /   F e b r u a r y   h a s   2 9   d a y s   i n   a n y   y e a r   e v e n l y   d i v i s i b l e   b y   f o u r ,  
         / /   E X C E P T   f o r   c e n t u r i a l   y e a r s   w h i c h   a r e   n o t   a l s o   d i v i s i b l e   b y   4 0 0 .  
         r e t u r n   (     ( ( y e a r   %   4   = =   0 )   & &   (   ( ! ( y e a r   %   1 0 0   = =   0 ) )   | |   ( y e a r   %   4 0 0   = =   0 )   )   )   ?   2 9   :   2 8   ) ;  
 }  
  
  
  
 / /   i s D a t e   ( S T R I N G   y e a r ,   S T R I N G   m o n t h ,   S T R I N G   d a y )  
 / /  
 / /   i s D a t e   r e t u r n s   t r u e   i f   s t r i n g   a r g u m e n t s   y e a r ,   m o n t h ,   a n d   d a y    
 / /   f o r m   a   v a l i d   d a t e .  
 / /    
  
 f u n c t i o n   i s D a t e   ( y e a r ,   m o n t h ,   d a y )  
 {       / /   c a t c h   i n v a l i d   y e a r s   ( n o t   2 -   o r   4 - d i g i t )   a n d   i n v a l i d   m o n t h s   a n d   d a y s .  
         i f   ( !   ( i s Y e a r ( y e a r ,   f a l s e )   & &   i s M o n t h ( m o n t h ,   f a l s e )   & &   i s D a y ( d a y ,   f a l s e ) ) )   r e t u r n   f a l s e ;  
  
         / /   E x p l i c i t l y   c h a n g e   t y p e   t o   i n t e g e r   t o   m a k e   c o d e   w o r k   i n   b o t h  
         / /   J a v a S c r i p t   1 . 1   a n d   J a v a S c r i p t   1 . 2 .  
         v a r   i n t Y e a r   =   p a r s e I n t ( y e a r ) ;  
         v a r   i n t M o n t h   =   p a r s e I n t ( m o n t h ) ;  
         v a r   i n t D a y   =   p a r s e I n t ( d a y ) ;  
  
         / /   c a t c h   i n v a l i d   d a y s ,   e x c e p t   f o r   F e b r u a r y  
         i f   ( i n t D a y   >   d a y s I n M o n t h [ i n t M o n t h ] )   r e t u r n   f a l s e ;    
  
         i f   ( ( i n t M o n t h   = =   2 )   & &   ( i n t D a y   >   d a y s I n F e b r u a r y ( i n t Y e a r ) ) )   r e t u r n   f a l s e ;  
  
         r e t u r n   t r u e ;  
 }  
  
  
  
  
 / *   F U N C T I O N S   T O   N O T I F Y   U S E R   O F   I N P U T   R E Q U I R E M E N T S   O R   M I S T A K E S .   * /  
  
  
 / /   D i s p l a y   p r o m p t   s t r i n g   s   i n   s t a t u s   b a r .  
  
 f u n c t i o n   p r o m p t   ( s )  
 {       w i n d o w . s t a t u s   =   s  
 }  
  
  
  
 / /   D i s p l a y   d a t a   e n t r y   p r o m p t   s t r i n g   s   i n   s t a t u s   b a r .  
  
 f u n c t i o n   p r o m p t E n t r y   ( s )  
 {       w i n d o w . s t a t u s   =   p E n t r y P r o m p t   +   s  
 }  
  
  
  
  
 / /   N o t i f y   u s e r   t h a t   r e q u i r e d   f i e l d   t h e F i e l d   i s   e m p t y .  
 / /   S t r i n g   s   d e s c r i b e s   e x p e c t e d   c o n t e n t s   o f   t h e F i e l d . v a l u e .  
 / /   P u t   f o c u s   i n   t h e F i e l d   a n d   r e t u r n   f a l s e .  
  
 f u n c t i o n   w a r n E m p t y   ( t h e F i e l d ,   s )  
 {       t h e F i e l d . f o c u s ( )  
         a l e r t ( m P r e f i x   +   s   +   m S u f f i x )  
         r e t u r n   f a l s e  
 }  
  
  
  
 / /   N o t i f y   u s e r   t h a t   c o n t e n t s   o f   f i e l d   t h e F i e l d   a r e   i n v a l i d .  
 / /   S t r i n g   s   d e s c r i b e s   e x p e c t e d   c o n t e n t s   o f   t h e F i e l d . v a l u e .  
 / /   P u t   s e l e c t   t h e F i e l d ,   p u   f o c u s   i n   i t ,   a n d   r e t u r n   f a l s e .  
  
 f u n c t i o n   w a r n I n v a l i d   ( t h e F i e l d ,   s )  
 {       t h e F i e l d . f o c u s ( )  
         t h e F i e l d . s e l e c t ( )  
         a l e r t ( s )  
         r e t u r n   f a l s e  
 }  
  
  
  
  
 / *   F U N C T I O N S   T O   I N T E R A C T I V E L Y   C H E C K   V A R I O U S   F I E L D S .   * /  
  
 / /   c h e c k S t r i n g   ( T E X T F I E L D   t h e F i e l d ,   S T R I N G   s ,   [ ,   B O O L E A N   e m p t y O K = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   n o t   a l l   w h i t e s p a c e .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k S t r i n g   ( t h e F i e l d ,   s ,   e m p t y O K )  
 {       / /   N e x t   l i n e   i s   n e e d e d   o n   N N 3   t o   a v o i d   " u n d e f i n e d   i s   n o t   a   n u m b e r "   e r r o r  
         / /   i n   e q u a l i t y   c o m p a r i s o n   b e l o w .  
         i f   ( c h e c k S t r i n g . a r g u m e n t s . l e n g t h   = =   2 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         i f   ( i s W h i t e s p a c e ( t h e F i e l d . v a l u e ) )    
               r e t u r n   w a r n E m p t y   ( t h e F i e l d ,   s ) ;  
         e l s e   r e t u r n   t r u e ;  
 }  
  
  
  
 / /   c h e c k S t a t e C o d e   ( T E X T F I E L D   t h e F i e l d   [ ,   B O O L E A N   e m p t y O K = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   U . S .   s t a t e   c o d e .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k S t a t e C o d e   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k S t a t e C o d e . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         e l s e  
         {     t h e F i e l d . v a l u e   =   t h e F i e l d . v a l u e . t o U p p e r C a s e ( ) ;  
               i f   ( ! i s S t a t e C o d e ( t h e F i e l d . v a l u e ,   f a l s e ) )    
                     r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i S t a t e C o d e ) ;  
               e l s e   r e t u r n   t r u e ;  
         }  
 }  
  
  
  
 / /   t a k e s   Z I P S t r i n g ,   a   s t r i n g   o f   5   o r   9   d i g i t s ;  
 / /   i f   9   d i g i t s ,   i n s e r t s   s e p a r a t o r   h y p h e n  
  
 f u n c t i o n   r e f o r m a t Z I P C o d e   ( Z I P S t r i n g )  
 {       i f   ( Z I P S t r i n g . l e n g t h   = =   5 )   r e t u r n   Z I P S t r i n g ;  
         e l s e   r e t u r n   ( r e f o r m a t   ( Z I P S t r i n g ,   " " ,   5 ,   " - " ,   4 ) ) ;  
 }  
  
  
  
  
 / /   c h e c k Z I P C o d e   ( T E X T F I E L D   t h e F i e l d   [ ,   B O O L E A N   e m p t y O K = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   Z I P   c o d e .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k Z I P C o d e   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k Z I P C o d e . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         e l s e  
         {   v a r   n o r m a l i z e d Z I P   =   s t r i p C h a r s I n B a g ( t h e F i e l d . v a l u e ,   Z I P C o d e D e l i m i t e r s )  
             i f   ( ! i s Z I P C o d e ( n o r m a l i z e d Z I P ,   f a l s e ) )    
                   r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i Z I P C o d e ) ;  
             e l s e    
             {     / /   i f   y o u   d o n ' t   w a n t   t o   i n s e r t   a   h y p h e n ,   c o m m e n t   n e x t   l i n e   o u t  
                   t h e F i e l d . v a l u e   =   r e f o r m a t Z I P C o d e ( n o r m a l i z e d Z I P )  
                   r e t u r n   t r u e ;  
             }  
         }  
 }  
  
  
  
 / /   t a k e s   U S P h o n e ,   a   s t r i n g   o f   1 0   d i g i t s  
 / /   a n d   r e f o r m a t s   a s   ( 1 2 3 )   4 5 6 - 7 8 9  
  
 f u n c t i o n   r e f o r m a t U S P h o n e   ( U S P h o n e )  
 {       r e t u r n   ( r e f o r m a t   ( U S P h o n e ,   " ( " ,   3 ,   " )   " ,   3 ,   " - " ,   4 ) )  
 }  
  
  
  
 / /   c h e c k U S P h o n e   ( T E X T F I E L D   t h e F i e l d   [ ,   B O O L E A N   e m p t y O K = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   U S   P h o n e .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k U S P h o n e   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k U S P h o n e . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         e l s e  
         {     v a r   n o r m a l i z e d P h o n e   =   s t r i p C h a r s I n B a g ( t h e F i e l d . v a l u e ,   p h o n e N u m b e r D e l i m i t e r s )  
               i f   ( ! i s U S P h o n e N u m b e r ( n o r m a l i z e d P h o n e ,   f a l s e ) )    
                     r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i U S P h o n e ) ;  
               e l s e    
               {     / /   i f   y o u   d o n ' t   w a n t   t o   r e f o r m a t   a s   ( 1 2 3 )   4 5 6 - 7 8 9 ,   c o m m e n t   n e x t   l i n e   o u t  
                     t h e F i e l d . v a l u e   =   r e f o r m a t U S P h o n e ( n o r m a l i z e d P h o n e )  
                     r e t u r n   t r u e ;  
               }  
         }  
 }  
  
  
  
 / /   c h e c k I n t e r n a t i o n a l P h o n e   ( T E X T F I E L D   t h e F i e l d   [ ,   B O O L E A N   e m p t y O K = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   I n t e r n a t i o n a l   P h o n e .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k I n t e r n a t i o n a l P h o n e   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k I n t e r n a t i o n a l P h o n e . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         e l s e  
         {     i f   ( ! i s I n t e r n a t i o n a l P h o n e N u m b e r ( t h e F i e l d . v a l u e ,   f a l s e ) )    
                     r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i W o r l d P h o n e ) ;  
               e l s e   r e t u r n   t r u e ;  
         }  
 }  
  
  
  
 / /   c h e c k E m a i l   ( T E X T F I E L D   t h e F i e l d   [ ,   B O O L E A N   e m p t y O K = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   E m a i l .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k E m a i l   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k E m a i l . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         e l s e   i f   ( ! i s E m a i l ( t h e F i e l d . v a l u e ,   f a l s e ) )    
               r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i E m a i l ) ;  
         e l s e   r e t u r n   t r u e ;  
 }  
  
  
  
 / /   t a k e s   S S N ,   a   s t r i n g   o f   9   d i g i t s  
 / /   a n d   r e f o r m a t s   a s   1 2 3 - 4 5 - 6 7 8 9  
  
 f u n c t i o n   r e f o r m a t S S N   ( S S N )  
 {       r e t u r n   ( r e f o r m a t   ( S S N ,   " " ,   3 ,   " - " ,   2 ,   " - " ,   4 ) )  
 }  
  
  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   S S N .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k S S N   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k S S N . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         e l s e  
         {     v a r   n o r m a l i z e d S S N   =   s t r i p C h a r s I n B a g ( t h e F i e l d . v a l u e ,   S S N D e l i m i t e r s )  
               i f   ( ! i s S S N ( n o r m a l i z e d S S N ,   f a l s e ) )    
                     r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i S S N ) ;  
               e l s e    
               {     / /   i f   y o u   d o n ' t   w a n t   t o   r e f o r m a t s   a s   1 2 3 - 4 5 6 - 7 8 9 0 ,   c o m m e n t   n e x t   l i n e   o u t  
                     t h e F i e l d . v a l u e   =   r e f o r m a t S S N ( n o r m a l i z e d S S N )  
                     r e t u r n   t r u e ;  
               }  
         }  
 }  
  
  
  
  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   Y e a r .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k Y e a r   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k Y e a r . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         i f   ( ! i s Y e a r ( t h e F i e l d . v a l u e ,   f a l s e ) )    
               r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i Y e a r ) ;  
         e l s e   r e t u r n   t r u e ;  
 }  
  
  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   M o n t h .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k M o n t h   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k M o n t h . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         i f   ( ! i s M o n t h ( t h e F i e l d . v a l u e ,   f a l s e ) )    
               r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i M o n t h ) ;  
         e l s e   r e t u r n   t r u e ;  
 }  
  
  
 / /   C h e c k   t h a t   s t r i n g   t h e F i e l d . v a l u e   i s   a   v a l i d   D a y .  
 / /  
 / /   F o r   e x p l a n a t i o n   o f   o p t i o n a l   a r g u m e n t   e m p t y O K ,  
 / /   s e e   c o m m e n t s   o f   f u n c t i o n   i s I n t e g e r .  
  
 f u n c t i o n   c h e c k D a y   ( t h e F i e l d ,   e m p t y O K )  
 {       i f   ( c h e c k D a y . a r g u m e n t s . l e n g t h   = =   1 )   e m p t y O K   =   d e f a u l t E m p t y O K ;  
         i f   ( ( e m p t y O K   = =   t r u e )   & &   ( i s E m p t y ( t h e F i e l d . v a l u e ) ) )   r e t u r n   t r u e ;  
         i f   ( ! i s D a y ( t h e F i e l d . v a l u e ,   f a l s e ) )    
               r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i D a y ) ;  
         e l s e   r e t u r n   t r u e ;  
 }  
  
  
  
 / /   c h e c k D a t e   ( y e a r F i e l d ,   m o n t h F i e l d ,   d a y F i e l d ,   S T R I N G   l a b e l S t r i n g   [ ,   O K t o O m i t D a y = = f a l s e ] )  
 / /  
 / /   C h e c k   t h a t   y e a r F i e l d . v a l u e ,   m o n t h F i e l d . v a l u e ,   a n d   d a y F i e l d . v a l u e    
 / /   f o r m   a   v a l i d   d a t e .  
 / /  
 / /   I f   t h e y   d o n ' t ,   l a b e l S t r i n g   ( t h e   n a m e   o f   t h e   d a t e ,   l i k e   " B i r t h   D a t e " )  
 / /   i s   d i s p l a y e d   t o   t e l l   t h e   u s e r   w h i c h   d a t e   f i e l d   i s   i n v a l i d .  
 / /  
 / /   I f   i t   i s   O K   f o r   t h e   d a y   f i e l d   t o   b e   e m p t y ,   s e t   o p t i o n a l   a r g u m e n t  
 / /   O K t o O m i t D a y   t o   t r u e .     I t   d e f a u l t s   t o   f a l s e .  
  
 f u n c t i o n   c h e c k D a t e   ( y e a r F i e l d ,   m o n t h F i e l d ,   d a y F i e l d ,   l a b e l S t r i n g ,   O K t o O m i t D a y )  
 {       / /   N e x t   l i n e   i s   n e e d e d   o n   N N 3   t o   a v o i d   " u n d e f i n e d   i s   n o t   a   n u m b e r "   e r r o r  
         / /   i n   e q u a l i t y   c o m p a r i s o n   b e l o w .  
         i f   ( c h e c k D a t e . a r g u m e n t s . l e n g t h   = =   4 )   O K t o O m i t D a y   =   f a l s e ;  
         i f   ( ! i s Y e a r ( y e a r F i e l d . v a l u e ) )   r e t u r n   w a r n I n v a l i d   ( y e a r F i e l d ,   i Y e a r ) ;  
         i f   ( ! i s M o n t h ( m o n t h F i e l d . v a l u e ) )   r e t u r n   w a r n I n v a l i d   ( m o n t h F i e l d ,   i M o n t h ) ;  
         i f   (   ( O K t o O m i t D a y   = =   t r u e )   & &   i s E m p t y ( d a y F i e l d . v a l u e )   )   r e t u r n   t r u e ;  
         e l s e   i f   ( ! i s D a y ( d a y F i e l d . v a l u e ) )    
               r e t u r n   w a r n I n v a l i d   ( d a y F i e l d ,   i D a y ) ;  
         i f   ( i s D a t e   ( y e a r F i e l d . v a l u e ,   m o n t h F i e l d . v a l u e ,   d a y F i e l d . v a l u e ) )  
               r e t u r n   t r u e ;  
         a l e r t   ( i D a t e P r e f i x   +   l a b e l S t r i n g   +   i D a t e S u f f i x )  
         r e t u r n   f a l s e  
 }  
  
  
  
 / /   G e t   c h e c k e d   v a l u e   f r o m   r a d i o   b u t t o n .  
  
 f u n c t i o n   g e t R a d i o B u t t o n V a l u e   ( r a d i o )  
 {       f o r   ( v a r   i   =   0 ;   i   <   r a d i o . l e n g t h ;   i + + )  
         {       i f   ( r a d i o [ i ] . c h e c k e d )   {   b r e a k   }  
         }  
         r e t u r n   r a d i o [ i ] . v a l u e  
 }  
  
  
  
  
 / /   V a l i d a t e   c r e d i t   c a r d   i n f o .  
  
 f u n c t i o n   c h e c k C r e d i t C a r d   ( r a d i o ,   t h e F i e l d )  
 {       v a r   c a r d T y p e   =   g e t R a d i o B u t t o n V a l u e   ( r a d i o )  
         v a r   n o r m a l i z e d C C N   =   s t r i p C h a r s I n B a g ( t h e F i e l d . v a l u e ,   c r e d i t C a r d D e l i m i t e r s )  
         i f   ( ! i s C a r d M a t c h ( c a r d T y p e ,   n o r m a l i z e d C C N ) )    
               r e t u r n   w a r n I n v a l i d   ( t h e F i e l d ,   i C r e d i t C a r d P r e f i x   +   c a r d T y p e   +   i C r e d i t C a r d S u f f i x ) ;  
         e l s e    
         {     t h e F i e l d . v a l u e   =   n o r m a l i z e d C C N  
               r e t u r n   t r u e  
         }  
 }  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         C r e d i t   c a r d   v e r i f i c a t i o n   f u n c t i o n s  
         O r i g i n a l l y   i n c l u d e d   a s   S t a r t e r   A p p l i c a t i o n   1 . 0 . 0   i n   L i v e P a y m e n t .  
         2 0   F e b   1 9 9 7   m o d i f i e d   b y   e g k :  
                       c h a n g e d   n a m i n g   c o n v e n t i o n   t o   i n i t i a l   l o w e r c a s e  
                                     ( i s M a s t e r C a r d   i n s t e a d   o f   I s M a s t e r C a r d ,   e t c . )  
                       c h a n g e d   i s C C   t o   i s C r e d i t C a r d  
                       r e t a i n e d   f u n c t i o n s   n a m e d   w i t h   o l d e r   c o n v e n t i o n s   f r o m  
                                     L i v e P a y m e n t   a s   s t u b   f u n c t i o n s   f o r   b a c k w a r d    
                                     c o m p a t i b i l i t y   o n l y  
                       a d d e d   " A M E R I C A N E X P R E S S "   a s   e q u i v a l e n t   o f   " A M E X "    
                                     f o r   n a m i n g   c o n s i s t e n c y    
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s C r e d i t C a r d ( s t )  
    
         I N P U T :           s t   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   p a s s e s   t h e   L u h n   M o d - 1 0  
 	 	         t e s t .  
 	             f a l s e ,   o t h e r w i s e  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s C r e d i t C a r d ( s t )   {  
     / /   E n c o d i n g   o n l y   w o r k s   o n   c a r d s   w i t h   l e s s   t h a n   1 9   d i g i t s  
     i f   ( s t . l e n g t h   >   1 9 )  
         r e t u r n   ( f a l s e ) ;  
  
     s u m   =   0 ;   m u l   =   1 ;   l   =   s t . l e n g t h ;  
     f o r   ( i   =   0 ;   i   <   l ;   i + + )   {  
         d i g i t   =   s t . s u b s t r i n g ( l - i - 1 , l - i ) ;  
         t p r o d u c t   =   p a r s e I n t ( d i g i t   , 1 0 ) * m u l ;  
         i f   ( t p r o d u c t   > =   1 0 )  
             s u m   + =   ( t p r o d u c t   %   1 0 )   +   1 ;  
         e l s e  
             s u m   + =   t p r o d u c t ;  
         i f   ( m u l   = =   1 )  
             m u l + + ;  
         e l s e  
             m u l - - ;  
     }  
 / /   U n c o m m e n t   t h e   f o l l o w i n g   l i n e   t o   h e l p   c r e a t e   c r e d i t   c a r d   n u m b e r s  
 / /   1 .   C r e a t e   a   d u m m y   n u m b e r   w i t h   a   0   a s   t h e   l a s t   d i g i t  
 / /   2 .   E x a m i n e   t h e   s u m   w r i t t e n   o u t  
 / /   3 .   R e p l a c e   t h e   l a s t   d i g i t   w i t h   t h e   d i f f e r e n c e   b e t w e e n   t h e   s u m   a n d  
 / /         t h e   n e x t   m u l t i p l e   o f   1 0 .  
  
 / /     d o c u m e n t . w r i t e l n ( " < B R > S u m             =   " , s u m , " < B R > " ) ;  
 / /     a l e r t ( " S u m             =   "   +   s u m ) ;  
  
     i f   ( ( s u m   %   1 0 )   = =   0 )  
         r e t u r n   ( t r u e ) ;  
     e l s e  
         r e t u r n   ( f a l s e ) ;  
  
 }   / /   E N D   F U N C T I O N   i s C r e d i t C a r d ( )  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s V i s a ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   V I S A   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
  
         S a m p l e   n u m b e r :   4 1 1 1   1 1 1 1   1 1 1 1   1 1 1 1   ( 1 6   d i g i t s )  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s V i s a ( c c )  
 {  
     i f   ( ( ( c c . l e n g t h   = =   1 6 )   | |   ( c c . l e n g t h   = =   1 3 ) )   & &  
             ( c c . s u b s t r i n g ( 0 , 1 )   = =   4 ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
 }     / /   E N D   F U N C T I O N   i s V i s a ( )  
  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s M a s t e r C a r d ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   M a s t e r C a r d  
 	 	         n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
  
         S a m p l e   n u m b e r :   5 5 0 0   0 0 0 0   0 0 0 0   0 0 0 4   ( 1 6   d i g i t s )  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s M a s t e r C a r d ( c c )  
 {  
     f i r s t d i g   =   c c . s u b s t r i n g ( 0 , 1 ) ;  
     s e c o n d d i g   =   c c . s u b s t r i n g ( 1 , 2 ) ;  
     i f   ( ( c c . l e n g t h   = =   1 6 )   & &   ( f i r s t d i g   = =   5 )   & &  
             ( ( s e c o n d d i g   > =   1 )   & &   ( s e c o n d d i g   < =   5 ) ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
  
 }   / /   E N D   F U N C T I O N   i s M a s t e r C a r d ( )  
  
  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s A m e r i c a n E x p r e s s ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   A m e r i c a n  
 	 	         E x p r e s s   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
  
         S a m p l e   n u m b e r :   3 4 0 0 0 0 0 0 0 0 0 0 0 0 9   ( 1 5   d i g i t s )  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s A m e r i c a n E x p r e s s ( c c )  
 {  
     f i r s t d i g   =   c c . s u b s t r i n g ( 0 , 1 ) ;  
     s e c o n d d i g   =   c c . s u b s t r i n g ( 1 , 2 ) ;  
     i f   ( ( c c . l e n g t h   = =   1 5 )   & &   ( f i r s t d i g   = =   3 )   & &  
             ( ( s e c o n d d i g   = =   4 )   | |   ( s e c o n d d i g   = =   7 ) ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
  
 }   / /   E N D   F U N C T I O N   i s A m e r i c a n E x p r e s s ( )  
  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s D i n e r s C l u b ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   D i n e r ' s  
 	 	         C l u b   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
  
         S a m p l e   n u m b e r :   3 0 0 0 0 0 0 0 0 0 0 0 0 4   ( 1 4   d i g i t s )  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s D i n e r s C l u b ( c c )  
 {  
     f i r s t d i g   =   c c . s u b s t r i n g ( 0 , 1 ) ;  
     s e c o n d d i g   =   c c . s u b s t r i n g ( 1 , 2 ) ;  
     i f   ( ( c c . l e n g t h   = =   1 4 )   & &   ( f i r s t d i g   = =   3 )   & &  
             ( ( s e c o n d d i g   = =   0 )   | |   ( s e c o n d d i g   = =   6 )   | |   ( s e c o n d d i g   = =   8 ) ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
 }  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s C a r t e B l a n c h e ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   C a r t e  
 	 	         B l a n c h e   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s C a r t e B l a n c h e ( c c )  
 {  
     r e t u r n   i s D i n e r s C l u b ( c c ) ;  
 }  
  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s D i s c o v e r ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   D i s c o v e r  
 	 	         c a r d   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
  
         S a m p l e   n u m b e r :   6 0 1 1 0 0 0 0 0 0 0 0 0 0 0 4   ( 1 6   d i g i t s )  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s D i s c o v e r ( c c )  
 {  
     f i r s t 4 d i g s   =   c c . s u b s t r i n g ( 0 , 4 ) ;  
     i f   ( ( c c . l e n g t h   = =   1 6 )   & &   ( f i r s t 4 d i g s   = =   " 6 0 1 1 " ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
  
 }   / /   E N D   F U N C T I O N   i s D i s c o v e r ( )  
  
  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s E n R o u t e ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   e n R o u t e  
 	 	         c a r d   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
  
         S a m p l e   n u m b e r :   2 0 1 4 0 0 0 0 0 0 0 0 0 0 9   ( 1 5   d i g i t s )  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s E n R o u t e ( c c )  
 {  
     f i r s t 4 d i g s   =   c c . s u b s t r i n g ( 0 , 4 ) ;  
     i f   ( ( c c . l e n g t h   = =   1 5 )   & &  
             ( ( f i r s t 4 d i g s   = =   " 2 0 1 4 " )   | |  
               ( f i r s t 4 d i g s   = =   " 2 1 4 9 " ) ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
 }  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s J C B ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a   v a l i d   J C B  
 	 	         c a r d   n u m b e r .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s J C B ( c c )  
 {  
     f i r s t 4 d i g s   =   c c . s u b s t r i n g ( 0 , 4 ) ;  
     i f   ( ( c c . l e n g t h   = =   1 6 )   & &  
             ( ( f i r s t 4 d i g s   = =   " 3 0 8 8 " )   | |  
               ( f i r s t 4 d i g s   = =   " 3 0 9 6 " )   | |  
               ( f i r s t 4 d i g s   = =   " 3 1 1 2 " )   | |  
               ( f i r s t 4 d i g s   = =   " 3 1 5 8 " )   | |  
               ( f i r s t 4 d i g s   = =   " 3 3 3 7 " )   | |  
               ( f i r s t 4 d i g s   = =   " 3 5 2 8 " ) ) )  
         r e t u r n   i s C r e d i t C a r d ( c c ) ;  
     r e t u r n   f a l s e ;  
  
 }   / /   E N D   F U N C T I O N   i s J C B ( )  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s A n y C a r d ( )  
    
         I N P U T :           c c   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   a n y   v a l i d   c r e d i t  
 	 	         c a r d   n u m b e r   f o r   a n y   o f   t h e   a c c e p t e d   c a r d   t y p e s .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s A n y C a r d ( c c )  
 {  
     i f   ( ! i s C r e d i t C a r d ( c c ) )  
         r e t u r n   f a l s e ;  
     i f   ( ! i s M a s t e r C a r d ( c c )   & &   ! i s V i s a ( c c )   & &   ! i s A m e r i c a n E x p r e s s ( c c )   & &   ! i s D i n e r s C l u b ( c c )   & &  
             ! i s D i s c o v e r ( c c )   & &   ! i s E n R o u t e ( c c )   & &   ! i s J C B ( c c ) )   {  
         r e t u r n   f a l s e ;  
     }  
     r e t u r n   t r u e ;  
  
 }   / /   E N D   F U N C T I O N   i s A n y C a r d ( )  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         F U N C T I O N :     i s C a r d M a t c h ( )  
    
         I N P U T :         c a r d T y p e   -   a   s t r i n g   r e p r e s e n t i n g   t h e   c r e d i t   c a r d   t y p e  
 	             c a r d N u m b e r   -   a   s t r i n g   r e p r e s e n t i n g   a   c r e d i t   c a r d   n u m b e r  
  
         R E T U R N S :     t r u e ,   i f   t h e   c r e d i t   c a r d   n u m b e r   i s   v a l i d   f o r   t h e   p a r t i c u l a r  
 	             c r e d i t   c a r d   t y p e   g i v e n   i n   " c a r d T y p e " .  
 	 	          
 	             f a l s e ,   o t h e r w i s e  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   i s C a r d M a t c h   ( c a r d T y p e ,   c a r d N u m b e r )  
 {  
  
 	 c a r d T y p e   =   c a r d T y p e . t o U p p e r C a s e ( ) ;  
 	 v a r   d o e s M a t c h   =   t r u e ;  
  
 	 i f   ( ( c a r d T y p e   = =   " V I S A " )   & &   ( ! i s V i s a ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 i f   ( ( c a r d T y p e   = =   " M A S T E R C A R D " )   & &   ( ! i s M a s t e r C a r d ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 i f   (   (   ( c a r d T y p e   = =   " A M E R I C A N E X P R E S S " )   | |   ( c a r d T y p e   = =   " A M E X " )   )  
                                 & &   ( ! i s A m e r i c a n E x p r e s s ( c a r d N u m b e r ) ) )   d o e s M a t c h   =   f a l s e ;  
 	 i f   ( ( c a r d T y p e   = =   " D I S C O V E R " )   & &   ( ! i s D i s c o v e r ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 i f   ( ( c a r d T y p e   = =   " J C B " )   & &   ( ! i s J C B ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 i f   ( ( c a r d T y p e   = =   " D I N E R S " )   & &   ( ! i s D i n e r s C l u b ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 i f   ( ( c a r d T y p e   = =   " C A R T E B L A N C H E " )   & &   ( ! i s C a r t e B l a n c h e ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 i f   ( ( c a r d T y p e   = =   " E N R O U T E " )   & &   ( ! i s E n R o u t e ( c a r d N u m b e r ) ) )  
 	 	 d o e s M a t c h   =   f a l s e ;  
 	 r e t u r n   d o e s M a t c h ;  
  
 }     / /   E N D   F U N C T I O N   C a r d M a t c h ( )  
  
  
  
  
 / *     = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
         T h e   b e l o w   s t u b   f u n c t i o n s   a r e   r e t a i n e d   f o r   b a c k w a r d   c o m p a t i b i l i t y  
         w i t h   t h e   o r i g i n a l   L i v e P a y m e n t   c o d e   s o   t h a t   i t   s h o u l d   b e   p o s s i b l e  
         i n   p r i n c i p l e   t o   s w a p   i n   t h i s   n e w   m o d u l e   a s   a   r e p l a c e m e n t   f o r   t h e      
         o l d e r   m o d u l e   w i t h o u t   b r e a k i n g   e x i s t i n g   c o d e .     ( T h e r e   a r e   n o  
         g u a r a n t e e s ,   o f   c o u r s e ,   b u t   i t   s h o u l d   w o r k . )  
  
         W h e n   w r i t i n g   n e w   c o d e ,   d o   n o t   u s e   t h e s e   s t u b   f u n c t i o n s ;   u s e   t h e  
         f u n c t i o n s   d e f i n e d   a b o v e .  
         = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 f u n c t i o n   I s C C   ( s t )   {  
         r e t u r n   i s C r e d i t C a r d ( s t ) ;  
 }  
  
 f u n c t i o n   I s V i s a   ( c c )     {  
     r e t u r n   i s V i s a ( c c ) ;  
 }  
  
 f u n c t i o n   I s V I S A   ( c c )     {  
     r e t u r n   i s V i s a ( c c ) ;  
 }  
  
 f u n c t i o n   I s M a s t e r C a r d   ( c c )     {  
     r e t u r n   i s M a s t e r C a r d ( c c ) ;  
 }  
  
 f u n c t i o n   I s M a s t e r c a r d   ( c c )     {  
     r e t u r n   i s M a s t e r C a r d ( c c ) ;  
 }  
  
 f u n c t i o n   I s M C   ( c c )     {  
     r e t u r n   i s M a s t e r C a r d ( c c ) ;  
 }  
  
 f u n c t i o n   I s A m e r i c a n E x p r e s s   ( c c )     {  
     r e t u r n   i s A m e r i c a n E x p r e s s ( c c ) ;  
 }  
  
 f u n c t i o n   I s A m E x   ( c c )     {  
     r e t u r n   i s A m e r i c a n E x p r e s s ( c c ) ;  
 }  
  
 f u n c t i o n   I s D i n e r s C l u b   ( c c )     {  
     r e t u r n   i s D i n e r s C l u b ( c c ) ;  
 }  
  
 f u n c t i o n   I s D C   ( c c )     {  
     r e t u r n   i s D i n e r s C l u b ( c c ) ;  
 }  
  
 f u n c t i o n   I s D i n e r s   ( c c )     {  
     r e t u r n   i s D i n e r s C l u b ( c c ) ;  
 }  
  
 f u n c t i o n   I s C a r t e B l a n c h e   ( c c )     {  
     r e t u r n   i s C a r t e B l a n c h e ( c c ) ;  
 }  
  
 f u n c t i o n   I s C B   ( c c )     {  
     r e t u r n   i s C a r t e B l a n c h e ( c c ) ;  
 }  
  
 f u n c t i o n   I s D i s c o v e r   ( c c )     {  
     r e t u r n   i s D i s c o v e r ( c c ) ;  
 }  
  
 f u n c t i o n   I s E n R o u t e   ( c c )     {  
     r e t u r n   i s E n R o u t e ( c c ) ;  
 }  
  
 f u n c t i o n   I s e n R o u t e   ( c c )     {  
     r e t u r n   i s E n R o u t e ( c c ) ;  
 }  
  
 f u n c t i o n   I s J C B   ( c c )     {  
     r e t u r n   i s J C B ( c c ) ;  
 }  
  
 f u n c t i o n   I s A n y C a r d ( c c )     {  
     r e t u r n   i s A n y C a r d ( c c ) ;  
 }  
  
 f u n c t i o n   I s C a r d M a t c h   ( c a r d T y p e ,   c a r d N u m b e r )     {  
     r e t u r n   i s C a r d M a t c h   ( c a r d T y p e ,   c a r d N u m b e r ) ;  
 }  
  
  
 f u n c t i o n   I s D i g i t S t r ( s t r )  
   {  
   	 i f ( s t r . l e n g t h = = 0 )   r e t u r n   f a l s e ;  
   	 f o r ( i = 0 ; i < s t r . l e n g t h ; i + + )  
 	 	 i f ( s t r . c h a r A t ( i ) < " 0 "   | |   s t r . c h a r A t ( i ) > " 9 " )  
 	 	  
 	 	 	 r e t u r n   f a l s e ;  
   	 r e t u r n   t r u e ;  
   } 
