Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/12/2011, 09:01
cheterporras2
 
Fecha de Ingreso: octubre-2011
Mensajes: 160
Antigüedad: 12 años, 6 meses
Puntos: 2
Respuesta: seguridad en formulario

Entonces, ¿la manera correcta de hacerlo sería ésta? (es que no sé si lo he entendido correctamente):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<link href="estilos.css" rel="stylesheet" type="text/css" />
<link href="registro.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
<!--
function validatePass(nombreamo) {
var RegExPattern = /(?!^[0-9]*$)(?!^[a-zA-Z áéíóúñÑÁÉÍÓÚü]*$)^([a-zA-Z áéíóúñÑÁÉÍÓÚü 0-9]{3,25})$/;
var errorMessage = 'Nombre Incorrecto.';
return false //no submit
if ((campo.value.match(RegExPattern)) && (campo.value!='')) {
} else {
alert(errorMessage);
}
}

function validarEmail(email) {
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3,4})+$/.test($email)){
} else {
alert("La dirección de email es incorrecta.");
return false //no submit

}
}



function ValidaCampos(telefono)
{
//comprueba campo teléfono de formulario
//usa el metodo test de expresion regular

if(/^([0-9+s+-])+$/.test($telefono)) {
}
else
{
alert('El número de teléfono ingresado no es válido.');
return false; //no submit
}
}

//-->
</script>


</head>

<body class="fondoregistro">
<form onsubmit="return (validatePass(this.nombreamo) && validarEmail(this.email) && ValidaCampos(this.telefono))" action="registrandose.php" method="post" enctype="multipart/form-data" id="formulario">
<table width="1024" height="774" border="0">
<tr>
<td width="312" rowspan="10" >&nbsp;</td>
<td width="349" height="90">&nbsp;</td>
<td width="349" height="90">&nbsp;</td>
</tr>
<tr>
<td height="30"><label for="pais"></label>
<label for="ciudad"></label>
<input name="pais" type="text" class="campotexto2" id="textfield3" maxlength="25" /></td>
<td height="30">
<table width="76%" border="0">
<tr>
<td width="50%" height="31">
<input type="radio" class="opcionpedigri" id="radio" value="si" checked name="pedigri"/>
<label for="si"></label></td>
<td width="50%"><input name="pedigri" type="radio" class="opcionpedigri" id="radio2" value="no" />
<label for="no"></label></td>
</tr>
</table></td>
</tr>
<tr>
<td height="30">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td height="30"><label for="zona"></label>
<input name="provincia" type="text" class="campotexto" id="textfield4" maxlength="25" /></td>
<td height="30"><label for="telefono"></label>
<input name="capa" type="text" class="campotexto" id="textfield11" maxlength="25" /></td>
</tr>
<tr>
<td height="30">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td height="30"><label for="especie"></label>
<input name="ciudad" type="text" class="campotexto" id="textfield5" maxlength="25" /></td>
<td height="30"><label for="email"></label>
<input name="nombreamo" type="text" class="campotexto" id="textfield12" maxlength="25" /></td>
</tr>
<tr>
<td height="30">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td height="30"><label for="raza"></label>
<input name="zona" type="text" class="campotexto" id="textfield6" maxlength="25" /></td>
<td height="30"><label for="usuario"></label>
<input name="telefono" type="text" class="campotexto" id="textfield13" maxlength="15" /></td>
</tr>
<tr>
<td height="30">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td height="30"><label for="edad"></label>
<input name="especie" type="text" class="campotexto" id="textfield7" maxlength="25" /></td>
<td height="30"><label for="contrasenna"></label>
<input name="email" type="text" class="campotexto" id="textfield14" maxlength="40" /></td>
</tr>
<tr>
<td height="45"><label for="foto"></label>
<input name="foto" type="file" class="foto" id="foto" size="30" /></td>
<td height="45">&nbsp;</td>
<td height="45">&nbsp;</td>
</tr>
<tr>
<td rowspan="6">&nbsp;</td>
<td height="30"><label for="sexo"></label>
<input name="raza" type="text" class="campotexto" id="textfield8" maxlength="25" /></td>
<td height="30"><label for="repcontrasenna"></label>
<input name="usuario" type="text" class="campotexto" id="textfield15" maxlength="25" /></td>
</tr>
<tr>
<td height="30">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td height="30"><label for="capa"></label>
<input name="edad" type="text" class="campotexto" id="textfield9" maxlength="2" /></td>
<td height="30"><label for="textfield16"></label>
<input name="contrasenna" type="password" class="campotexto" id="textfield16" maxlength="25" /></td>
</tr>
<tr>
<td height="30">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td height="31"><label for="nombreamo"></label>
<label for="sexo"></label>
<select name="sexo" size="1" class="campotexto" id="sexo">
<option selected="selected">macho</option>
<option>hembra</option>
</select></td>
<td height="31"><label for="textfield17"></label>
<input name="repcontrasenna" type="password" class="campotexto" id="textfield17" maxlength="25" /></td>
</tr>
<tr>
<td height="45">&nbsp;</td>
<td ><input type="submit" name="button" id="button" value="Enviar"/></td>
</tr>
</table>
</form>
</body>
</html>

Última edición por cheterporras2; 31/12/2011 a las 09:08