mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 08:23:46 +00:00
gestion des champs "requiered"
This commit is contained in:
parent
53a632fe59
commit
1d93912e7f
1 changed files with 16 additions and 15 deletions
|
@ -92,38 +92,39 @@ function submitBday() {
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
{% can_edit user %}
|
{% can_edit user %}
|
||||||
<div class="disclaimer" style="display:none;">
|
<div class="disclaimer" style="display:none;" id="div_disclaimer">
|
||||||
<input type="checkbox" id="check_disclaimer" name="box_disclaimer" requiered=True />
|
<input type="checkbox" id="{{userform.disclaimer.auto_id}}" name="box_disclaimer" requiered=True />
|
||||||
<label for="scales">Décharge parentale reçue</label>
|
<label for="scales">Décharge parentale reçue</label>
|
||||||
|
</div>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="disclaimer" style="display:none;">
|
<div class="disclaimer" style="display:none;" id="div_disclaimer">
|
||||||
{{ userform.disclaimer.label_tag }}
|
{{ userform.disclaimer.label_tag }}
|
||||||
{% render_field userform.disclaimer class="form-control" %}
|
{% render_field userform.disclaimer class="form-control" requiered=True %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
function submitBday() {
|
function submitBday() {
|
||||||
var fields = document.getElementsByClassName("disclaimer");
|
var div = document.getElementById("div_disclaimer");
|
||||||
|
var input = document.getElementById("{{userform.disclaimer.auto_id}}");
|
||||||
|
|
||||||
var Bdate = document.getElementById('bday').value;
|
var Bdate = document.getElementById('bday').value;
|
||||||
var Bday = +new Date(Bdate);
|
var Bday = +new Date(Bdate);
|
||||||
var age = ((Date.now() - Bday) / (31557600000));
|
var age = ((Date.now() - Bday) / (31557600000));
|
||||||
|
|
||||||
var len = fields.length;
|
console.log("{{userform.disclaimer.auto_id}}");
|
||||||
|
|
||||||
if (age < 18){
|
if (age < 18){
|
||||||
for (i=0; i<len; ++i) {
|
div.style.display = "block";
|
||||||
fields[i].style.display = "block";
|
input.setAttribute("requiered", "True");
|
||||||
fields[i].required = true;
|
console.log(input);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
for (i=0; i<len; ++i) {
|
div.style.display = "none";
|
||||||
fields[i].style.display = "none";
|
input.removeAttribute("requiered");
|
||||||
fields[i].required = false;
|
console.log(input);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue