Checker d'intégrité de tous les params JS
This commit is contained in:
parent
7f06c170c9
commit
ec277d538b
36
Patients.php
36
Patients.php
|
@ -3,7 +3,11 @@ require('autoloader.php');
|
||||||
if(!Authentification::checkUser(0)){
|
if(!Authentification::checkUser(0)){
|
||||||
header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
|
header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
|
||||||
die();
|
die();
|
||||||
};?>
|
};
|
||||||
|
|
||||||
|
// formattage $_GET['type']
|
||||||
|
$answerType = (isset($_GET['type'])) ? $_GET['type'] : null;
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -46,7 +50,19 @@ if(!Authentification::checkUser(0)){
|
||||||
<!-- FIL D'ARIANE -->
|
<!-- FIL D'ARIANE -->
|
||||||
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Medecins.php'>Gestion des médecins</a></a> </div>
|
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Medecins.php'>Gestion des médecins</a></a> </div>
|
||||||
|
|
||||||
<?php/********************************/
|
<?php if( $answerType != null ){
|
||||||
|
|
||||||
|
echo '<span>';
|
||||||
|
switch($answerType){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default: echo 'rien à déclarer ? Non!'; break;
|
||||||
|
}
|
||||||
|
echo '</span>';
|
||||||
|
|
||||||
|
}
|
||||||
|
/*************************************/
|
||||||
/* AJOUTER UN PATIENT */
|
/* AJOUTER UN PATIENT */
|
||||||
/*************************************/ ?>
|
/*************************************/ ?>
|
||||||
<article data-title="Ajouter un patient">
|
<article data-title="Ajouter un patient">
|
||||||
|
@ -65,17 +81,17 @@ if(!Authentification::checkUser(0)){
|
||||||
+ medecin_traitant
|
+ medecin_traitant
|
||||||
-->
|
-->
|
||||||
<br><h4>Ajout d'un nouveau patient</h4>
|
<br><h4>Ajout d'un nouveau patient</h4>
|
||||||
<input type='text' id='crPrenom' name='prenom' placeholder='Prénom' value=''><br>
|
<input type='text' id='crPrenom' name='prenom' placeholder='Prénom' value='' required><br>
|
||||||
<input type='text' id='crNom' name='nom' placeholder='NOM' value=''><br>
|
<input type='text' id='crNom' name='nom' placeholder='NOM' value='' required><br>
|
||||||
<input type='radio' name='civilite' value='M' id='civ1' checked><label for='civ1'>Homme</label><br>
|
<input type='radio' name='civilite' value='M' id='civ1' checked><label for='civ1'>Homme</label><br>
|
||||||
<input type='radio' name='civilite' value='F' id='civ2'><label for='civ2'>Femme</label><br>
|
<input type='radio' name='civilite' value='F' id='civ2'><label for='civ2'>Femme</label><br>
|
||||||
<input type='text' id='crAdr' name='adresse' placeholder='Adresse' value=''><br>
|
<input type='text' id='crAdr' name='adresse' placeholder='Adresse' value='' required><br>
|
||||||
<input type='text' id='crAdr2' name='adresse2' placeholder='Complément adresse' value=''><br>
|
<input type='text' id='crAdr2' name='adresse2' placeholder='Complément adresse' value=''><br>
|
||||||
<input type='text' id='crCP' name='code_postal' placeholder='09000' value=''><span class='info'>Code postal</span><br>
|
<input type='text' id='crCP' name='code_postal' placeholder='09000' value='' required><span class='info'>Code postal</span><br>
|
||||||
<input type='text' id='crVille' name='ville' placeholder='Ville' value=''><br>
|
<input type='text' id='crVille' name='ville' placeholder='Ville' value='' required><br>
|
||||||
<input type='text' id='crDN' name='date_naissance' placeholder='jj/mm/aaaa' value=''><span class='info'>Date de naissance</span><br>
|
<input type='text' id='crDN' name='date_naissance' placeholder='jj/mm/aaaa' value='' required><span class='info'>Date de naissance</span><br>
|
||||||
<input type='text' id='crLN' name='lieu_naissance' placeholder='Ville de naissance' value=''><br>
|
<input type='text' id='crLN' name='lieu_naissance' placeholder='Ville de naissance' value='' required><br>
|
||||||
<input type='text' id='crSecu' name='num_secu' placeholder='1 99 19 99 999 999 99' value=''><span class='info'>Numéro de sécurité sociale</span><br>
|
<input type='text' id='crSecu' name='num_secu' placeholder='1 99 19 99 999 999 99' value='' required><span class='info'>Numéro de sécurité sociale</span><br>
|
||||||
|
|
||||||
<span>Choix du médecin traitant (optionnel)</span><br>
|
<span>Choix du médecin traitant (optionnel)</span><br>
|
||||||
<select id='crMedecin' name='id_medecin'><?php
|
<select id='crMedecin' name='id_medecin'><?php
|
||||||
|
|
|
@ -263,7 +263,13 @@ body{
|
||||||
background-size: auto 100%;
|
background-size: auto 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#CONTAINER > span{
|
||||||
|
margin: 1.8em;
|
||||||
|
|
||||||
|
color: #f00;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************/
|
/******************************/
|
||||||
/* ARTICLES (cadres internes) */
|
/* ARTICLES (cadres internes) */
|
||||||
|
@ -470,6 +476,12 @@ body{
|
||||||
|
|
||||||
/* extra */
|
/* extra */
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-khtml-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
/* animation */
|
/* animation */
|
||||||
transition: all .2s ease-in-out;
|
transition: all .2s ease-in-out;
|
||||||
|
|
|
@ -36,13 +36,13 @@ function checkVARCHAR(pInputElement, pMinLength, pMaxLength, optAlpha){
|
||||||
if( optAlpha ) varcharRegExp = new RegExp('^([a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
|
if( optAlpha ) varcharRegExp = new RegExp('^([a-z]{'+pMinLength+','+pMaxLength+'})$', 'i'); // only alpha characters
|
||||||
else varcharRegExp = new RegExp('^([\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
|
else varcharRegExp = new RegExp('^([\\w -]{'+ pMinLength+','+pMaxLength+'})$', 'i'); // any word character
|
||||||
|
|
||||||
if( pInputElement.value.match(varcharRegExp) != null ){ // si champ correct
|
if( pInputElement.value.match(varcharRegExp) != null || pInputElement.value == '' ){ // si champ correct
|
||||||
addClass(pInputElement, 'validated');
|
addClass(pInputElement, 'validated');
|
||||||
remClass(pInputElement, 'invalid');
|
if( pInputElement.required ) remClass(pInputElement, 'invalid');
|
||||||
}else{
|
}else{
|
||||||
remClass(pInputElement, 'validated');
|
remClass(pInputElement, 'validated');
|
||||||
|
|
||||||
addClass(pInputElement, 'invalid');
|
if( pInputElement.required ) addClass(pInputElement, 'invalid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +133,21 @@ inSecu.addEventListener('keyup', function(e){
|
||||||
sbCreer.addEventListener('click', function(e){
|
sbCreer.addEventListener('click', function(e){
|
||||||
e.preventDefault(); // on annule le submit()
|
e.preventDefault(); // on annule le submit()
|
||||||
|
|
||||||
var inputCheckerValid = inCk.checkAll();
|
var formElements = sbCreer.parentNode.children;
|
||||||
var allInputValidated = inPrenom.className.indexOf('validated') > -1 && inNom.className.indexOf('validated') > -1 && inAdr.className.indexOf('validated') > -1 && inAdr2.className.indexOf('validated') > -1 && inCP.className.indexOf('validated') > -1 && inVille.className.indexOf('validated') > -1 && inDN.className.indexOf('validated') > -1 && inLN.className.indexOf('validated') > -1 && inSecu.className.indexOf('validated') > -1;
|
var checker = true;
|
||||||
|
|
||||||
if( inputCheckerValid && allInputValidated ) // si tout es ok uniquement, on submit()
|
// pour chaque <input type='text'> du formulaire (fils direct uniquement)
|
||||||
|
for( var i = 0 ; i < formElements.length ; i++ ){ if( formElements[i] instanceof HTMLInputElement && formElements[i].type == 'text' ){
|
||||||
|
// si le champ est requis (required)
|
||||||
|
if( formElements[i].required )
|
||||||
|
checker = checker && formElements[i].className.indexOf('validated') > -1; // TRUE => validé (niveau interface)
|
||||||
|
// si le champ n'est pas requis et pas vide, on le vide
|
||||||
|
else if( formElements[i].value != '' && formElements[i].className.indexOf('validated') < 0) // si incorrect et pas vide
|
||||||
|
formElements[i].value = ''; // on vide
|
||||||
|
}}
|
||||||
|
|
||||||
|
var inputCheckerValid = inCk.checkAll();
|
||||||
|
|
||||||
|
if( inputCheckerValid && checker ) // si tout es ok uniquement, on submit()
|
||||||
sbCreer.parentNode.submit();
|
sbCreer.parentNode.submit();
|
||||||
}, false);
|
}, false);
|
Loading…
Reference in New Issue