Add user creation form validation
This commit is contained in:
parent
77e604d385
commit
095b639794
|
@ -7,7 +7,7 @@
|
|||
<link rel="stylesheet" href="../../static/style.css" type="text/css" media="screen" />
|
||||
<script src="../../static/jquery-3.5.1.min.js"></script>
|
||||
<script src="../ajax.js"></script>
|
||||
<script src="../validate_id.js"></script>
|
||||
<script src="../validate_patient.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
@ -16,7 +16,7 @@
|
|||
$pdo = connectDatabase();
|
||||
$regions = fetchRegions($pdo);
|
||||
?>
|
||||
<form name="create_form" method="post" action="../patient_management.php" onsubmit="return validateDNI();">
|
||||
<form name="create_form" method="post" action="../patient_management.php" onsubmit="return validatePatient();">
|
||||
<div class="input-group">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="nombre" value="">
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../../static/style.css" type="text/css" media="screen" />
|
||||
<script src="../validate_user.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="../user_management.php">
|
||||
<form name="create_form" method="post" action="../user_management.php" onsubmit="return validateUser();">
|
||||
<div class="input-group">
|
||||
<label>Nombre</label>
|
||||
<input type="text" name="nombre" value="">
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
function validateString(input){
|
||||
if(input == ""){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function validateEmail(input){
|
||||
var emailID = input;
|
||||
atpos = emailID.indexOf("@");
|
||||
dotpos = emailID.lastIndexOf(".");
|
||||
|
||||
if (atpos < 1 || ( dotpos - atpos < 2 )) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function validateUser(){
|
||||
var name = document.forms["create_form"]["nombre"];
|
||||
var user = document.forms["create_form"]["usuario"];
|
||||
var password = document.forms["create_form"]["contraseña"];
|
||||
var email = document.forms["create_form"]["correo"];
|
||||
|
||||
if(!validateString(name.value)){
|
||||
alert("Introduce el nombre");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!validateString(user.value)){
|
||||
alert("Introduce el usuario");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!validateString(password.value)){
|
||||
alert("Introduce la contraseña");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!validateEmail(email.value)){
|
||||
alert("El correo proporcionado es incorrecto");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue