Comment faire de la saisie de texte où automatique avec décimal ','?Entrée de texte décimal automatique
<td><?= $form->field($model, 'Payment')->textInput(['maxlength' => 7, 'style' => 'width:120px;'])?></td>
Comment faire de la saisie de texte où automatique avec décimal ','?Entrée de texte décimal automatique
<td><?= $form->field($model, 'Payment')->textInput(['maxlength' => 7, 'style' => 'width:120px;'])?></td>
<input type="number" id="decimalvalue" name="decimalvalue" onkeyup="setDecimalValue()">
<script>
function setDecimalValue() {
var num = $('#decimalvalue').val();
var n = num.toFixed(2);
$('#decimalvalue').val(n);
}
</script>
<td><?= $form->field($model, 'Payment')->textInput([
'maxlength' => 7,
'style' => 'width:120px;'
'type' => 'number', // this will set input to decimal number format
'step' => '0.0001' // and this
])?></td>
En yu nous avons l'option de format numérique personnalisé. pour cela, nous devons remplacer la fonction de formatage existante.
vous pouvez consulter le lien ci-dessous pour plus de détails. http://www.yiiframework.com/wiki/360/custom-number-formatting-or-decimal-separators-and-i18n/
<input type="number" onchange="setTwoNumberDecimal" min="0" max="10" step="0.25" value="0.00" />
function setTwoNumberDecimal(event) {
this.value = parseFloat(this.value).toFixed(2);
}