I'm trying to manipulate dates with jQuery. The idea is as follows:
The user informs Data_vencimento
and type (in radio button
), whether the payment will be weekly, biweekly, monthly or informed.
In% with% entered, the user will enter the number of days (for example, 20 days) so that jQuery can calculate the maturities.
Example:
input
with date 11/21/2018. (14 + 7). Only input #dt_venc1
returns a alert(dtVenc1)
.
How do I manipulate dates with jQuery? It seems that manipulating with dates with PHP is a lot easier. But with jQuery, it would be independent of the language used.
$(document).ready( function () {
$('#data_vencimento').on('blur', function() {
alert('Usuário utilizando o input "DATA_VENCIMENTO"');
var dtVenc = new Date();
var dtVenc1 = new Date();
dtVenc = $('#data_vencimento').val();
dtVenc1 = dtVenc1.setDate(dtVenc1 + 7);
alert(dtVenc);
alert(dtVenc1);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="row">
<div class="form-group col-md-2">
<label class="control-label" for="data_vencimento">Data Vencimento *</label>
<input type="text" class="form-control datepicker required" name="data_vencimento" id="data_vencimento">
</div>
<div class="form-group col-md-2">
<label class="control-label" for="data_prorrogacao">Data Prorrogacao</label>
<input type="text" class="form-control datepicker" name="data_prorrogacao" id="data_prorrogacao">
</div>
</div>
<div class="row">
<div class="form-check form-check-radio form-check-inline">
<label class="form-check-label" >Tipo de Parcelamento:</label>
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="SEMANAL"> Semanal
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
<div class="form-check form-check-radio form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="QUINZENAL" checked="checked"> Quinzenal
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
<div class="form-check form-check-radio form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="MENSAL" checked="checked"> Mensal
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
<div class="form-check form-check-radio form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio4" value="INFORMADO"> Informado
<span class="circle">
<span class="check"></span>
</span>
</label>
</div>
<div class="col-md-2">
<div class="form-group has-label">
<label class="bmd-label-floating" for="dias">Qtd. dias</label>
<input class="numero form-control" type="text" name="dias" size="03"
id="dias">
</div>
</div>
</div>