JavaScript - problemas con el submit

 
Vista:

problemas con el submit

Publicado por mauricio (1 intervención) el 10/08/2015 15:55:21
el problema que tengo es que al enviar el formulario no valida, ni tira ningun error nada


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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<html>
<head>
<link rel="stylesheet" type="text/css" href= "1.css">
<script language=javascript>
function validar(){
				var a= document.getElementById("modelo1").value;
				var b= document.getElementById("machine1").value;
				var c= document.getElementById("serie1").value;
				var d= document.getElementById("modulo1").value;
				var f= document.getElementById("fecha1").value;
				var g= document.getElementById("lugar1").value;
				var h= document.getElementById("cargo1").value;
				var i= document.getElementById("institucion1").value;
				var j= document.getElementById("contacto1").value;
				var k= document.getElementById("telefono1").value;
				var l= document.getElementById("servicio1").value;
				var p= document.getElementById("submit").value;
				if ( a == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( b == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( c == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( d == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( f == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( g == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( h == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( i == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( j == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( k == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( l == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
				if ( n == "") {
					alert("porfavor digite el modelo");
					retrun false;
				}
 
}
 
</script>
</head>
<body>
 
<table class = "tabla" >
	<tr>
		<td class ="div>
			<div class ="div">
				<FORM id="form" method="post" action="1.php" onSubmit="retrun validar();">
					<table>
						<tr> <td></td><td><center>Equipo 1</center></td>
						</tr>
						<tr><td> Modelo</td><td> <input class="a" type="text" name="modelo1" id="modelo1"  ></td></tr>
						<tr><td>Machine Type</td><td><INPUT class="a"  type="text" name="machine1" id="machine1"></td> </tr>
						<tr><td>N de Serie </td><td> <input class="a"  type="text" name="serie1" id="serie1" value="" ></td></tr>
						<tr><td>N de Modulo</td><td><INPUT class="a"  type="text" name="modulo1" id="modulo1"></td> </tr>
						<tr><td>Fecha de instalacion</td><td><INPUT class="a"  type="text" name="fecha1" id="fecha1"></td> </tr>
						<tr><td> Nombre y Apellido </td><td> <INPUT class="a"  type="text" name="nombre1" id="nombre1"></td></tr>
						<tr><td> Cargo</td><td> <INPUT class="a"  type="text" name="cargo1" id="cargo1"></td></tr>
						<tr><td> Lugar y Fecha </td><td> <INPUT class="a"  type="text" name="lugar1" id="lugar1"></td></tr>
						<tr><td> Nombre de la Instituci&oacuten</td><td> <INPUT class="a"  type="text" name="institucion1" id="institucion1"></td></tr>
						<tr><td> Domicilio </td><td> <INPUT class="a"  type="text" name="domicilio1" id="domicilio1"></td></tr>
						<tr><td> Telefono </td><td> <INPUT class="a"  type="text" name="telefono1" id="telefono1"></td></tr>
						<tr><td> Persona de Contacto en el Servicio<br>(para coordinar reparaciones<bR> o realizar
								consultas<br> telefonicas sobre el)  </td><td> <textarea class="a"  rows="5" cols="22" type="text" name="contacto1" id="contacto1"></textarea>
							</td>
						</tr>
						<tr><td> Servicio donde se instalo </td><td> <INPUT class="a"  type="text" name="servicio1" id="servicio1"></td></tr>
						<tr><td> Distribuidor de AGFA / Vendedor </td><td> <INPUT class="a"  type="text" name="distribuidor1" id="distribuidor1"></td></tr>
						<tr><td colspan="2"><center><INPUT class="b" type="submit" id="submit" value="Generar Word"> <INPUT class="b" type="reset" value ="Borrar Campos"></center></td></tr>
					</table>
				</form>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de txema
Val: 71
Ha aumentado 1 puesto en JavaScript (en relación al último mes)
Gráfica de JavaScript

problemas con el submit

Publicado por txema (25 intervenciones) el 10/08/2015 16:34:30
Hola Mauricio:

He insertado algunos pequeños cambios tanto en Javascript como en HTML.
La falta de tabulación me hace difícil corregir algunos errores (posiblemente no todos), pero básicamente funciona de acuerdo a las reglas de validación marcadas (campos no vacíos):

Por Javascript:
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
<script>
function validar(){
var a= document.getElementById("modelo1").value;
var b= document.getElementById("machine1").value;
var c= document.getElementById("serie1").value;
var d= document.getElementById("modulo1").value;
var f= document.getElementById("fecha1").value;
var g= document.getElementById("lugar1").value;
var h= document.getElementById("cargo1").value;
var i= document.getElementById("institucion1").value;
var j= document.getElementById("contacto1").value;
var k= document.getElementById("telefono1").value;
var l= document.getElementById("servicio1").value;
if ( a == "") {
alert("porfavor digite el modelo");
}
if ( b == "") {
alert("porfavor digite el machine");
}
if ( c == "") {
alert("porfavor digite el serie");
}
if ( d == "") {
alert("porfavor digite el modulo");
}
if ( f == "") {
alert("porfavor digite el fecha");
}
if ( g == "") {
alert("porfavor digite el lugar");
}
if ( h == "") {
alert("porfavor digite el cargo");
}
if ( i == "") {
alert("porfavor digite el institucion");
}
if ( j == "") {
alert("porfavor digite el contacto");
}
if ( k == "") {
alert("porfavor digite el telefono");
}
if ( l == "") {
alert("porfavor digite el servicio");
}
}
</script>

Por HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<form id="form" method="post" action="" onSubmit="validar();">
<table>
<tr> <td></td><td><center>Equipo 1</center></td>
</tr>
<tr><td> Modelo</td><td> <input class="a" type="text" name="modelo1" id="modelo1" ></td></tr>
<tr><td>Machine Type</td><td><input class="a" type="text" name="machine1" id="machine1"></td> </tr>
<tr><td>N de Serie </td><td> <input class="a" type="text" name="serie1" id="serie1" value="" ></td></tr>
<tr><td>N de Modulo</td><td><input class="a" type="text" name="modulo1" id="modulo1"></td> </tr>
<tr><td>Fecha de instalacion</td><td><input class="a" type="text" name="fecha1" id="fecha1"></td> </tr>
<tr><td> Nombre y Apellido </td><td> <input class="a" type="text" name="nombre1" id="nombre1"></td></tr>
<tr><td> Cargo</td><td> <input class="a" type="text" name="cargo1" id="cargo1"></td></tr>
<tr><td> Lugar y Fecha </td><td> <input class="a" type="text" name="lugar1" id="lugar1"></td></tr>
<tr><td> Nombre de la Instituci&oacuten</td><td> <input class="a" type="text" name="institucion1" id="institucion1"></td></tr>
<tr><td> Domicilio </td><td> <input class="a" type="text" name="domicilio1" id="domicilio1"></td></tr>
<tr><td> Telefono </td><td> <input class="a" type="text" name="telefono1" id="telefono1"></td></tr>
<tr><td> Persona de Contacto en el Servicio<br>(para coordinar reparaciones<bR> o realizar
consultas<br> telefonicas sobre el) </td><td> <textarea class="a" rows="5" cols="22" type="text" name="contacto1" id="contacto1"></textarea>
</td>
</tr>
<tr><td> Servicio donde se instalo </td><td> <input class="a" type="text" name="servicio1" id="servicio1"></td></tr>
<tr><td> Distribuidor de AGFA / Vendedor </td><td> <input class="a" type="text" name="distribuidor1" id="distribuidor1"></td></tr>
<tr><td colspan="2"><center><input class="b" type="submit" id="submit" value="Generar Word"> <input class="b" type="reset" value ="Borrar Campos"></center></td></tr>
</table>
</form>

Coméntanos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar