Algunas validaciones en el form

parent 81f5c43c
...@@ -4,6 +4,7 @@ let cont_tecnologia = 0; ...@@ -4,6 +4,7 @@ let cont_tecnologia = 0;
const experiencias = []; const experiencias = [];
const estudios = []; const estudios = [];
const tecnologias = []; const tecnologias = [];
let noValidateFlag = false;
const formValidator = function () { const formValidator = function () {
'use strict' 'use strict'
...@@ -20,6 +21,7 @@ const formValidator = function () { ...@@ -20,6 +21,7 @@ const formValidator = function () {
if (!form.checkValidity()) { if (!form.checkValidity()) {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
noValidateFlag = true;
} }
form.classList.add('was-validated') form.classList.add('was-validated')
...@@ -225,15 +227,18 @@ form.addEventListener("submit",(evt)=>{ ...@@ -225,15 +227,18 @@ form.addEventListener("submit",(evt)=>{
// evt.stopPropagation() // evt.stopPropagation()
// } // }
// form.classList.add('was-validated') // form.classList.add('was-validated')
postData('postulante', serializeJSON(form)) if(!noValidateFlag){
.then(response => { postData('postulante', serializeJSON(form))
if(response.status==200 || response.status==302){ .then(response => {
location.replace(response.url); if(response.status==200 || response.status==302){
}else{ location.replace(response.url);
console.log(response.text().then(value => console.log(value))) }else{
} console.log(response.text().then(value => console.log(value)))
}); }
evt.preventDefault(); });
evt.preventDefault();
}
noValidateFlag = false
} ); } );
document.querySelector("#btn-new-tech").addEventListener('click',()=>{document.querySelector("#tecnologia-nombre").classList.remove('d-none')}) document.querySelector("#btn-new-tech").addEventListener('click',()=>{document.querySelector("#tecnologia-nombre").classList.remove('d-none')})
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<label>Nombre: ${postulante.nombre}</label><br> <label>Nombre: ${postulante.nombre}</label><br>
<label>Apellido ${postulante.apellido}</label><br> <label>Apellido ${postulante.apellido}</label><br>
<label>Tipo de documento: ${postulante.tipoDocumento}</label><br> <label>Tipo de documento: ${postulante.tipoDocumento}</label><br>
<label>Cedula: ${postulante.ci}</label><br> <label>Cedula: ${postulante.nroDocument}</label><br>
<label>Correo: ${postulante.correo}</label><br> <label>Correo: ${postulante.correo}</label><br>
<label>Departamento: ${postulante.getCiudad().getDepartamento().getNombre()}</label><br> <label>Departamento: ${postulante.getCiudad().getDepartamento().getNombre()}</label><br>
<label>Ciudad: ${postulante.getCiudad().getNombre()}</label><br> <label>Ciudad: ${postulante.getCiudad().getNombre()}</label><br>
......
...@@ -234,11 +234,11 @@ ...@@ -234,11 +234,11 @@
<div class="inputs col-md-6"> <label for="nivelIngles" class="form-label"> Nivel de ingles</label> <div class="inputs col-md-6"> <label for="nivelIngles" class="form-label"> Nivel de ingles</label>
<select name="nivelIngles" id="nivelIngles" class="bg-light"> <select name="nivelIngles" id="nivelIngles" class="bg-light">
<option value="1" selected>1</option> <option value="1" selected>Ingles muy basico</option>
<option value="2" >2</option> <option value="2" >Comprendo algunas cosas y puedo leer con la ayuda del traductor</option>
<option value="3" >3</option> <option value="3" >Puedo leer tranquilamente</option>
<option value="4" >4</option> <option value="4" >Puedo escribir documentacion</option>
<option value="5" >5</option> <option value="5" >Puedo escribir y hablar tranquilamente</option>
</select> </select>
</div> </div>
...@@ -312,22 +312,22 @@ ...@@ -312,22 +312,22 @@
<form name="experiencia-form" class="needs-validation" novalidate> <form name="experiencia-form" class="needs-validation" novalidate>
<div class="inputs"> <div class="inputs">
<label for="institucion" class="inputs form-label">Institucion</label> <label for="institucionExperiencia" class="inputs form-label">Institucion</label>
<input type="text" class="inputs form-control " name="institucion" id="institucion" required> <input type="text" class="inputs form-control " name="institucion" id="institucionExperiencia" required>
</div> </div>
<div class="inputs"> <div class="inputs">
<label for="fechaDesde" class="form-label">Fecha Desde</label> <label for="fechaDesdeExperiencia" class="form-label">Fecha Desde</label>
<input type="date" class="form-control " name="fechaDesde" id="fechaDesde" required> <input type="date" class="form-control" name="fechaDesde" id="fechaDesdeExperiencia" required>
</div> </div>
<div class="inputs"> <div class="inputs">
<label for="fechaHasta" class="form-label">Fecha Hasta</label> <label for="fechaHastaExperiencia" class="form-label">Fecha Hasta</label>
<input type="date" class="form-control " name="fechaHasta" id="fechaHasta" > <input type="date" class="form-control" name="fechaHasta" id="fechaHastaExperiencia" >
</div> </div>
<div class="inputs"> <div class="inputs">
<label for="cargo" class="form-label">Cargo</label> <label for="cargo" class="form-label">Cargo</label>
<input type="text" class="form-control " name="cargo" id="cargo" required> <input type="text" class="form-control " name="cargo" id="cargo" required>
</div> </div>
<div class="inputs"> <div class="inputs">
...@@ -434,8 +434,8 @@ ...@@ -434,8 +434,8 @@
<%-- <label for="tipoDeEstudio" class="form-label">Tipo De Estudio</label>--%> <%-- <label for="tipoDeEstudio" class="form-label">Tipo De Estudio</label>--%>
<%-- <input type="text" class="form-control " name="tipoDeEstudio" id="tipoDeEstudio">--%> <%-- <input type="text" class="form-control " name="tipoDeEstudio" id="tipoDeEstudio">--%>
<div class="form-group"> <div class="form-group">
<label for="institucion" class="form-label">Institucion</label> <label for="institucionEstudio" class="form-label">Institucion</label>
<input type="text" class="form-control" name="institucion" id="institucion" required> <input type="text" class="form-control" name="institucion" id="institucionEstudio" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="temaDeEstudio" class="form-label">Carrera/Bachiller/Tema de Curso</label> <label for="temaDeEstudio" class="form-label">Carrera/Bachiller/Tema de Curso</label>
...@@ -451,12 +451,12 @@ ...@@ -451,12 +451,12 @@
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="fechaDesde" class="form-label">Fecha Desde</label> <label for="fechaDesdeEstudio" class="form-label">Fecha Desde</label>
<input type="date" class="form-control " name="fechaDesde" id="fechaDesde" required> <input type="date" class="form-control " name="fechaDesde" id="fechaDesdeEstudio" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="fechaHasta" class="form-label">Fecha Hasta</label> <label for="fechaHastaEstudio" class="form-label">Fecha Hasta</label>
<input type="date" class="form-control " name="fechaHasta" id="fechaHasta" > <input type="date" class="form-control " name="fechaHasta" id="fechaHastaEstudio" >
</div> </div>
...@@ -480,7 +480,38 @@ ...@@ -480,7 +480,38 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script> <script>
var ciudades = ${ciudades}; var ciudades = ${ciudades};
(function(){
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
today = yyyy + '-' + mm + '-' + dd;
let fechaDesdeEstudio = document.querySelector("#fechaDesdeEstudio");
let fechaDesdeExperiencia = document.querySelector("#fechaDesdeExperiencia");
let fechaHastaEstudio = document.querySelector("#fechaHastaEstudio");
let fechaHastaExperiencia = document.querySelector("#fechaHastaExperiencia");
fechaDesdeEstudio.setAttribute("max", today);
fechaDesdeExperiencia.setAttribute("max", today);
fechaDesdeExperiencia.addEventListener("change", ()=>{
fechaHastaExperiencia.setAttribute("min", fechaDesdeExperiencia.value)
})
fechaDesdeEstudio.addEventListener("change", ()=>{
fechaHastaEstudio.setAttribute("min", fechaDesdeEstudio.value)
})
})()
</script> </script>
<script src="./main.js"></script> <script src="./main.js"></script>
</body> </body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment