From 77e604d385aedc3f316673dd430d73a268839827 Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 18 Jun 2020 08:06:39 +0200 Subject: [PATCH] Add patient creation form validation --- src/{validate_id.js => validate_patient.js} | 39 +++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) rename src/{validate_id.js => validate_patient.js} (50%) diff --git a/src/validate_id.js b/src/validate_patient.js similarity index 50% rename from src/validate_id.js rename to src/validate_patient.js index 17c4e39..f7cf560 100644 --- a/src/validate_id.js +++ b/src/validate_patient.js @@ -22,12 +22,45 @@ function checkDNI(dni) { } } -function validateDNI(){ +function validateString(input){ + if(input == ""){ + return false; + } + return true; +} + + +function validatePatient(){ + var name = document.forms["create_form"]["nombre"]; + var last_name = document.forms["create_form"]["apellido"]; var dni = document.forms["create_form"]["documento_identificativo"]; + var address = document.forms["create_form"]["direccion"]; + var country = document.forms["create_form"]["pais"]; + if(!checkDNI(dni.value)){ alert("El DNI/NIE no es correcto"); return false; - } - alert("El DNI/NIE es correcto"); + } + + if(!validateString(name.value)){ + alert("Introduce el nombre"); + return false; + } + + if(!validateString(last_name.value)){ + alert("Introduce el apellido"); + return false; + } + + if(!validateString(address.value)){ + alert("Introduce la dirección"); + return false; + } + + if(!validateString(country.value)){ + alert("Introduce el país"); + return false; + } + return true; }