文本输入自动小数

How to make text input where automatic with decimal ','?

<td><?= $form->field($model, 'Payment')->textInput(['maxlength' => 7, 'style' => 'width:120px;'])?></td>

enter image description here

<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>

In yii we have custom number format option. for this we have to override the existing format function.

you can refer below link for more details. 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);
}