f u n c t i o n   V a l i d a t e A n d S u b m i t ( )  
 {  
 	 v a r   m s g   =   " " ;  
 	 i f   ( d o c u m e n t . f o r m 1 . n o m . v a l u e   = =   " " )   	 m s g   + =   " -   I l   m a n q u e   l e   n o m \ n " ;  
 	 i f   ( d o c u m e n t . f o r m 1 . m a i l . v a l u e   = =   " " )   	 	 m s g   + =   " -   I l   m a n q u e   l ' a d r e s s e   m a i l \ n " ;  
 	 e l s e   i f   ( ! i s E m a i l ( d o c u m e n t . f o r m 1 . m a i l . v a l u e ) )   m s g   + =   " -   L e   f o r m a t   d ' a d r e s s e   m a i l   e s t   i n v a l i d e   ( " + d o c u m e n t . f o r m 1 . m a i l . v a l u e + " ) \ n "  
 	 i f   ( d o c u m e n t . f o r m 1 . m e s s a g e . v a l u e   = =   " " )   	 	 m s g   + =   " -   I l   m a n q u e   l e   m e s s a g e \ n " ;  
 	 i f   ( m s g   ! =   " " )    
 	 	 a l e r t ( m s g ) ;  
 	 e l s e    
 	 	 d o c u m e n t . f o r m 1 . s u b m i t ( ) ; 	  
 }  
 v a r   w h i t e s p a c e   =   "   \ t \ n \ r " ;  
 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 ) )  
 }  
 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 ;  
 }  
  
 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 ) )    
               r e t u r n   f a l s 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 ;  
 } 