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; }