I have this code on my View :
<div class="editor-label">
@Html.Label("Periode de Validation")
</div>
<div class="editor-field">
Mois:
<input data-val="true" data-val-number="The field PART1_MOIS must be a number."
id="PART1_MOIS" name="PART1_MOIS" style="width: 80px" type="text" value="" />
Ans :
<input data-val="true" data-val-number="The field PART1_ANS must be a number."
id="PART1_ANS" name="PART1_ANS" style="width: 80px" type="text" value="" />
Total en mois :
<input data-val="true" data-val-number="The field PART1_fPeriodeValid must be a number."
id="PART1_fPeriodeValid" name="PART1_fPeriodeValid" style="width: 80px" type="text" value="" />
@Html.ValidationMessageFor(model => model.fPeriodeValid)
</div>
I want to convert period in year + month in month, so i have this script :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>jQuery(function ($) {
$(":text[id*=_MOIS],:text[id*=_ANS]").blur(function () {
var MOIS = $(":text[id*=_MOIS]").val();
var ANS = $(":text[id*=_ANS]").val();
var total = MOIS / 1 + ANS * 12;
$(":text[id*=fPeriodeValid]").val(total);
});
});</script>
but I don't know how to save this result (input button periodeValid) on my database ...
I have tried this :
Total en mois :
<input data-val="true" data-val-number="The field PART1_fPeriodeValid must be a number." id="PART1_fPeriodeValid" name="PART1_fPeriodeValid" style="width: 80px" type="text" value="@Model.fPeriodeValide" />
My model is like this : public int? fPeriodeValid { get; set; }