timotta 7 de mai. de 2007
Acho q você devia colocar seu javascript num arquivo .js separado, ou no mínimo num JSP.
luistiagos 7 de mai. de 2007
para validar um email vc deve criar um algoritimo que primeiro avalie se existe uma String com um ou mais caracteres da posição 0 a posição onde se te o @ logo apos deve verificar se existe ao menos um caractere da posição @+1 ate a posição . e depois do ponto deve ter ao menos 3 caracteres…
public static final boolean validaEmail ( String strEmail ) {
if ( ! SICUtil . isFormatoValido ( strEmail )){
return false ;
}
StringBuffer bufferArroba = new StringBuffer ();
StringBuffer bufferPonto = new StringBuffer ();
int iPosarroba = 0 ;
int iPosponto = 0 ;
while ( strEmail . charAt ( iPosarroba ) != ‘@’ ) {
bufferArroba . append ( strEmail . charAt ( iPosarroba ));
if ( iPosarroba == ( strEmail . length () - 1 )){
return false ;
}
iPosarroba ++ ;
}
if ( bufferArroba . length () < 1 || iPosarroba + 2 > strEmail . length ()){
return false ;
}
iPosponto = iPosarroba + 2 ;
if ( strEmail . charAt ( iPosponto ) == ‘ . ’ ){
return false ;
}
while ( strEmail . charAt ( iPosponto ) != ‘ . ’ ) {
bufferPonto . append ( strEmail . charAt ( iPosponto ));
if ( iPosponto == strEmail . length () - 1 ){
return false ;
}
iPosponto ++ ;
}
if ( bufferPonto . length () < 1 || iPosponto + 2 > strEmail . length ()){
return false ;
}
return true ;
}
private static boolean isFormatoValido ( String strEmail ) {
if ( strEmail == null || strEmail .equals ( "" ) || strEmail .length () < 7 || strEmail .charAt ( 0 ) == '@' ) {
return false ;
}
return true ;
}
marcushlm 7 de mai. de 2007
testa assim
function isValidEmail ( str ) {
return ( str . indexOf ( "." ) > 2 ) && ( str . indexOf ( "@" ) > 0 );
}
fica bem simples, deve funcionar
emmanuel.silva 7 de mai. de 2007
Utilize expressões regulares, um exemplo de metodo para validar se um e-mail é valido em Java:
public static boolean verificaEmail ( String email ) {
return email . matches ( "^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}$" );
}
leandrosu 7 de mai. de 2007
Aeee…
Valeu galera…
Consegui aqui …
Brigado pela atençao …
[]s