i've been trying to do some validation on email format from a html form, i need to
read " @email.com.cc" and prompt to user that it is not a valid email format which
should be "[EMAIL PROTECTED]" instead.

how do i do this ? is this the norm of email validation ???
below is my program, when i run i have nullpointer exception at
MemberBean.testEmail
thank you for your attentions and inputs.

********************************************
import java.util.*;
import java.lang.*;

class MemberBean {

 double Day;
 double Month;
 double Year;
 String Email;
 String DOB;
 char e1, e2, e3;
 StringTokenizer T;

MemberBean (double day, double month, double year, String email, String dob) {

Day = day;
Month = month;
Year = year;
Email = email;
DOB = dob;
}

boolean testDate() {

 if(Month >=1&&Month <=12){
  if(Day >=1&&Day <=31){
  System.out.println("Date Validation Passed");
  }else
  System.out.println("Invalid Day");
 }else
 System.out.println("Invalid Month");

 return false;
 }

void testEmail(){

 int l = 0;
 String stringArray[] = new String[20];
        StringBuffer sbuf = new StringBuffer(Email );   // create a StringBuffer

        int s[  ] = new int[ 20 ];                 // array to hold length of
                                                   // each string
        // Build a StringBuffer with all the Strings concatenated
        for (int i = 0; i < 20; i++ )
        {
        s[ i ] = stringArray[ i ].length();   // save the length of each
         l += s[ i ];                                   // and the total length
         sbuf.append(stringArray[ i ]);              // concatenate the next string

         }
         String result = new String( sbuf );  // convert to String
         char ch[ ] = new char[ l ];             // create the char array
         ch = result.toCharArray( );             // and convert to char array

  System.out.println("Email "+ ch[l]);
//*************************************************
// if(ch!='@'){
//  System.out.println("Email Validation passed "+ ch);
//  S.pop();
// }else
//  System.out.println("Invalid Charater "+ ch);

 }

}

class verifyBean {
 public static void main(String args[]) {

 MemberBean verify1 = new MemberBean(1,12,00, "[EMAIL PROTECTED]", "12/08/78");
 MemberBean verify2 = new MemberBean(32,01,00, "[EMAIL PROTECTED]", "22/02/76");

 boolean date = false;
 date = verify1.testDate();
 verify1.testEmail();
 date = verify2.testDate();

 }
}
********************************************

deepty kj wrote:

> hi,
>   Better to use scripts for client side validation. If u need server-side
> validation use Bean.
>
> deepati
>
> On Tue, 23 May 2000 11:39:03 +0800, A mailing list about Java Server Pages
> specification and
>               reference wrote:
>
> >  hi Gurus,
> >
> >  can you pls show me the way to validate Email format (on html/jsp form
> >  input) ?
> >  what's the best way of doing it ? bean ? script ?
> >
> >  thank you for your attention,
> >  fay
> >
> >
> ===========================================================================
> >  To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> >  Some relevant FAQs on JSP/Servlets can be found at:
> >
> >   http://java.sun.com/products/jsp/faq.html
> >   http://www.esperanto.org.nz/jsp/jspfaq.html
> >   http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >   http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> _______________________________________________________
> Get 100% FREE Internet Access powered by Excite
> Visit http://freelane.excite.com/freeisp
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to