-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidacion.js
54 lines (47 loc) · 2.47 KB
/
validacion.js
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
//Haz tú validación en javascript acá
var validar = function(){
var nom = document.getElementById("nombre").value;
var email = document.getElementById("email").value;
var asunto = document.getElementById("asunto").value;
var mensaje = document.getElementById("mensaje").value;
if(nom==""){
alert("El campo nombre no puede esta vacio");
document.getElementById("nombre").focus();
}else{if(nom.length>50){
alert("El ccampo nombre no puede superar los 50 caracteres");
document.getElementById("nombre").focus();
}else{if(email==""){
alert("El campo email no puede esta vacio");
document.getElementById("email").focus();
}else{if(email.length>50){
alert("El campo email no puede superar los 50 caracteres");
document.getElementById("email").focus();
}else{if(asunto==""){
alert("El campo asunto no puede esta vacio");
document.getElementById("asunto").focus();
}else{if(asunto.length>50){
document.getElementById("boton").disabled = false;
alert("El campo asunto no puede superar los 50 caracteres");
document.getElementById("asunto").focus();
}else{if(mensaje==""){
alert("El campo mensaje no puede esta vacio");
document.getElementById("mensaje").focus();
}else{if(mensaje.length<300){
document.getElementById("boton").disabled = false;
document.getElementById("nombre").value="";
document.getElementById("email").value="";
document.getElementById("asunto").value="";
document.getElementById("mensaje").value="";
document.getElementById("nombre").focus();
}else{
alert("El campo mensaje no puede superar los 50 caracteres");
document.getElementById("mensaje").focus();
}
}
}
}
}
}
}
}
}