Re: oFF-Topic, validacion de forms con js
| From: | Alejandro F. Kapit | Date: | Thu, 14 Dec 2000 14:55:55 +0000 |
| Subject: | Re: oFF-Topic, validacion de forms con js | ||
| References: | 1 2 3 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-4991@lists.php.net to get a copy of this message | ||
Me estoy complicando como un logo y me saltan errores por todos lados, yo
tengo esto :
function Validate(){
if (document.login.email.value==""){
alert("Favor de escribir el email valido.");
return false;
}
if (document.login.password.value==""){
alert("Favor de escribir el password.");
return false;
}
return true;
}
y ahora quiero adaptarle a la misma funcion, la que vos me pasaste pero me
saltan errores hasta por la sopa!!! (por si no lo notaron esto ya es un
pedido de auxilio) jeje
----- Original Message -----
From: "Aldo F. Quezada V." <aldo@grupoweb.cl>
To: <lista@phpes.com>
Sent: Friday, December 14, 2001 11:25 AM
Subject: Re: [PHP-ES] oFF-Topic, validacion de forms con js
Visita la pagina http://javascript.internet.com ahi
encontraras recursos de
javascript, validaciones, etc, hay rutinas para validar las direcciones de
mail.
de todas maneras te envio el codigo
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<script language='javascript'>
<!-- Hide from old browsers
function check_email(form) {
// check if empty
if (form.email.value.length == 0)
alert('You need to enter a e-mail address before I can check it!')
else {
// check for @ position
PosAT = form.email.value.indexOf('@',0)
// check for . position after 1 character of the @ position
PosDot = form.email.value.indexOf('.',PosAT + 2)
// count number of characters after the . position
if (PosDot > -1)
CharsAfterDot = form.email.value.length - PosDot - 1
else
CharsAfterDot = -1
if ((PosAT == -1) || (PosDot == -1) ||
(CharsAfterDot <= 1) || (CharsAfterDot >= 4))
alert('This can not be a valid e-mail address');
else
alert('The e-mail address ' +
form.email.value +
' can be valid ... I think');
}
}
// Unhide -->
</script>
<FORM NAME="EForm">
Enter your e-mail address:
<INPUT TYPE="text" SIZE=30 NAME="email">
<INPUT TYPE="submit" NAME="check" VALUE="Check!"
onClick="check_email(this.form); return false;">
</FORM>
</BODY>
</HTML>