Ver Mensaje Individual
  #10 (permalink)  
Antiguo 27/03/2013, 03:06
nuria1254
 
Fecha de Ingreso: enero-2012
Mensajes: 30
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: validacion formulario campo telefono

mi codigo actual



<body>
<form method="POST" action="enviar.php" onSubmit="return validarform(this)" name="Forma">
<div align="center">
<table border="0" width="63%" cellspacing="0" cellpadding="0">
<tr>
<td width="45%" align="right">
<p style="margin-right: 10px; margin-top: 0; margin-bottom: 0">
<font face="Tahoma" size="2">Asunto</font></td>
<td width="55%">
<p style="margin-top: 0; margin-bottom: 0">
<input type="text" name="asunto" size="26" style="font-family: Tahoma; font-size: 8pt; width:140; height:20"></td>
</tr>
<tr>
<td width="45%" align="right">
<p style="margin-right: 10px; margin-top: 0; margin-bottom: 0">
<font face="Tahoma" size="2">Nombre</font></td>
<td width="55%">
<p style="margin-top: 0; margin-bottom: 0">
<input type="text" name="nombre" size="26" style="font-family: Tahoma; font-size: 8pt; width:140; height:20"></td>
</tr>
<tr>
<td align="right"><p style="margin-right: 10px; margin-top: 0; margin-bottom: 0"> <font face="Tahoma" size="2">Telefono</font></td>
<td><p style="margin-top: 0; margin-bottom: 0">
<input name="tel" type="text" id="tel" style="font-family: Tahoma; font-size: 8pt; width:140; height:20" size="26">
</td>
</tr>

<tr>
<td width="45%" align="right">
<p style="margin-right: 10px; margin-top: 0; margin-bottom: 0">
<font face="Tahoma" size="2">E-Mail</font></td>
<td width="55%">
<p style="margin-top: 0; margin-bottom: 0">
<input type="text" name="email" size="26" style="font-family: Tahoma; font-size: 8pt; width:140; height:20"></td>
</tr>
<tr>
<td valign="top" colspan="2">
<p align="center" style="margin-right: 10px; margin-top: 0; margin-bottom: 0">
<font face="Tahoma" size="2">Comentario</font></td>
</tr>
<tr>
<td valign="top" colspan="2">
<p style="margin-top: 0; margin-bottom: 0" align="center">
<textarea rows="8" name="comentario" cols="46" style="font-family: Tahoma; font-size: 8pt; width:243; height:49"></textarea></td>
</tr>
</table>
</div>

<p align="center" style="margin-top: 0; margin-bottom: 0">
<font face="Tahoma"><input type="submit" value="Enviar" name="B1">
<input type="reset" value="Borrar" name="B2"></font></p>
</form>
<p>

<SCRIPT>
<!--
function validarform(f)
{
if (f.asunto.value.length < 4) {
alert("Escribe un Minimo de 4 Letras Como Asunto");
Forma.asunto.focus();
return (false);
}
if (f.nombre.value.length < 4) {
alert("Escribe un Minimo de 4 Letras Como nombre");
Forma.nombre.focus();
return (false);
}

valor = document.getElementById("campo").value;
if( !(/^\d{9}$/.test(valor)) ) {
return false;
}

if (f.tel.value.length < 9) {
alert("Escribe un Minimo de 9 Digitos como Teléfono");
Forma.tel.focus();
return (false);
}

if((f.tel.value.indexOf(".") == -1)||
(f.tel.value.indexOf("@") == -1)||
(f.tel.value.length < 9)) {
alert("Telenono valido");
Forma.email.focus();
return (false);
}
if((f.email.value.indexOf(".") == -1)||
(f.email.value.indexOf("@") == -1)||
(f.email.value.length < 5)) {
alert("La Dirección de Correo No Es Válida");
Forma.email.focus();
return (false);
}
if (f.comentario.value.length < 10) {
alert("Se Requiere de un Minimo de 10 Letras Como Comentario");
Forma.comentario.focus();
return (false);
}
else
return true
}
// -->
</SCRIPT>





</body>

</html>


como hago los nuevos cambios?