Good evening everyone,
I have a problem with the website I'm coding. I have implemented a bootstrap form in the index.html and I have codded a Javascript script, which is linked to the HTML.
Here is the HTML:
<div class="container">
<div style="text-align:center">
<br>
<h5><span class="badge bg-primary shadow rounded">Enregistrer un résultat</span></h5>
<br>
</div>
<div class="container">
<div class="row">
<div class="col align-items-stretch" id="patient_form">
<div class="card shadow mb-5 bg-body rounded text-center" style='height: 430px;'>
<div class="card-header"><strong>Remplissez les informations du patient</strong></div>
<div class="card-body">
<p class="card-text">
<form class="form-inline" role="form">
<div class="form-floating mb-2">
<input class="form-control" id="patient_prenom" autocomplete="off" required/>
<label for="patient_prenom">Prénom</label>
</div>
<div class="form-floating mb-2">
<input class="form-control" id="patient_nom" autocomplete="off" required/>
<label for="patient_nom">Nom</label>
</div>
<div class="form-floating mb-2">
<input class="form-control" id="patient_date_naissance" type="date" required>
<label for="patient_date_naissance">Date de naissance</label>
</div>
<br>
<div class="text-center">
<button onclick="searchPatient()" type="submit" class="btn btn-primary btn-sm">Rechercher le patient</button>
</div>
</form>
</p>
</div>
</div>
</div>
And here is the Javascript script:
function searchPatient() {
prenom = document.getElementById('patient_prenom').value;
nom = document.getElementById('patient_nom').value;
date_naissance = document.getElementById('patient_date_naissance').value;
document.getElementById("patient_form").style.display = "none";
document.getElementById("intervention_form").style.display = "block";
document.getElementById("patient_recap").style.display = "block";
document.getElementById('patient_recap_text').innerHTML += '<h5>' + prenom + ' ' + nom + '<h5>' + '<h6>' + date_naissance + ' ' + '<h6>';
}
With this configuration, the "required" label in my first form is not working. But as soon as I'm deleting the line that links the Javascript to the HTML, it's working.
Can you please help me solving this issue?
Thank you very much!!