
Duda Validacion
Publicado por Facundo (1 intervención) el 18/04/2014 03:02:57
Buenas. Tengo una duda en la validacion. Los errores de validacion tienen q aparecer en el div q ta al final del formulario. En el script de validacion me toma el primero error pero al segundo ya no me lo toma y no me lo muestra en el div /: Alguien me podria ayudar o guiar? :/ Gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulario con validación de campos en jQuery</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var direccion = $("#txtDireccion").val();
var precio = $("#txtPrecio").val();
var expr = /^\d*$/;
$("#formPHP").submit(function () {
if(direccion == "") {
//document.getElementById("divResultado").innerHTML = "Direccion invalida </br>";
$("#divResultado").html("Direccion invalida");
return false;
}
if((!expr.test(precio)) || precio == ""){
//document.getElementById("divResultado").innerHTML = "Precio invalido";
$("#divResultado").html("Precio invalido </br>");
return false;
}
});
});
</script>
</style>
</head>
<body>
<h2>Formulario</h2>
<form action="" method="GET" id="formPHP" name="formPHP">
<table>
<tr>
<th>Tipo de Venta</th>
<td><select id="tipVenta" name="tipVenta"><option value="Departamento">Departamento</option><option value="Chalet">Chalet</option><option value="Casa">Casa</option></select></td>
</tr>
<tr>
<th>Departamento</th>
<td><select id="Dep" name="Dep"><option value="Palpala">Palpala</option><option value="San Pedro">San Pedro</option><option value="El Carmen">El Carmen</option><option value="Ledesma">Ledesma</option></select></td>
</tr>
<tr>
<th>Direccion</th>
<td><input type="text" id="txtDireccion" name="txtDireccion"/></td>
</tr>
<tr>
<th>Numero Dormitorio</th>
<td>1 <input type="radio" name="numDormitorio" value="1"/> 2 <input type="radio" name="numDormitorio" value="2"/> 3 <input type="radio" name="numDormitorio" value="3"/> 4 <input type="radio" name="numDormitorio" value="4"/></td>
</tr>
<tr>
<th>Precio</th>
<td><input type="text" id="txtPrecio" name="txtPrecio"/></td>
</tr>
<tr>
<th>Tamaño</th>
<td><input type="text"/ id="txtTamano" name="txtTamano"></td>
</tr>
<tr>
<th>Servicios</th>
<td>Telefono <input type="checkbox" value="Telefono"/> Luz <input type="checkbox" value="Luz"/> Agua <input type="checkbox" value="Agua"/></td>
</tr>
<tr>
<th>Correo Electronico</th>
<td><input type="text" id="txtCorreo" name="txtCorreo"/></td>
</tr>
<tr>
<th>Observacion</th>
<td><textarea></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Enviar Datos" id="btnEnviar" name="btnEnviar"/></td>
</tr>
<tr>
<td colspan="2" align="center"><div id="divResultado" name="divResultado"></div></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
Valora esta pregunta


0