Guest User

Untitled

a guest
Apr 1st, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. //Metodo para validar el formulario usuario
  2. function validarUsuario() {
  3.  
  4. //Asignamos los datos del formulario a las variables
  5. var rut = document.getElementById("txtRut").value;
  6. var nombre = document.getElementById("txtNombre").value;
  7. var apellido = document.getElementById("txtApellido").value;
  8. var edad = document.getElementById("txtEdad").value;
  9. var telefono = document.getElementById("txtTelefono").value;
  10. var pass = document.getElementById("txtPass").value;
  11. var pas2 = document.getElementById("txtPass2").value;
  12.  
  13. //var aux = /\w+@+\w+.[a-z]/;
  14.  
  15. //Validaciones
  16. if ( rut.length == 0 ) {
  17. alert("El Rut esta vacio!");
  18. } else if ( nombre.length == 0 ) {
  19. alert("El Nombre esta vacio!");
  20. } else if ( apellido.length == 0 ) {
  21. alert("El Apellido esta vacio!");
  22. } else if ( isNaN(edad) ) {
  23. alert("La edad no es correcta!");
  24. } else if ( telefono.length == 0 ) {
  25. alert("El Telefono esta vacio!");
  26. } else if ( pass.length == 0 ) {
  27. alert("La contraseña esta vacia!");
  28. } else if ( pas2.length == 0 ) {
  29. alert("La contraseña2 esta vacia!");
  30. }
  31. }
  32.  
  33. function validandoLogin() {
  34. var user = document.getElementById("txtUser").value;
  35. var pass = document.getElementById("txtPass").value;
  36.  
  37. if ( user.trim() == "Duoc" && pass.trim() == "1234" ) {
  38. document.write("<h3 style='text-align:center;'>Usuario: " + user + "</h3>");
  39. document.write("<h3 style='text-align:center;'>Contraseña: " + pass + "</h3>");
  40. location.href="formulario.html";
  41. return true;
  42. } else {
  43. alert("Usuario o contraseña incorrectos!");
  44. return false;
  45. }
  46. }
Add Comment
Please, Sign In to add comment