Page 187 - DCAP408_WEB_PROGRAMMING
P. 187

Unit 6: DOM Model




                 with  (field)                                                                  Notes
                   {
                     apos=value.indexOf(“@”);
                     dotpos=value.lastIndexOf(“.”);
                     if  (apos<1||dotpos-apos<2)
                         {alert(alerttxt);return  false;}
                     else  {return  true;}
                   }
                 }
                 function  validate_form(thisform)
                 {
                 with  (thisform)
                   {
                     if  (validate_email(email,”Not  a  valid  e-mail  address!”)==false)
                         {email.focus();return  false;}
                   }
                 }
                 </script>
                 </head>
                 <body>
                 <form  action=”submit.htm”  onsubmit=”return  validate_form(this);”
                 method=”post”>
                 Email:  <input  type=”text”  name=”email”  size=”30">
                 <input  type=”submit”  value=”Submit”>
                 </form>
                 </body>
                 </html>
          Output
          Without giving the @ the error will be like the below output.

                                             Figure  6.7

























                                           LOVELY PROFESSIONAL UNIVERSITY                                   181
   182   183   184   185   186   187   188   189   190   191   192