【问题标题】:Php Numeral Formatting and decimal separatorPhp 数字格式和小数分隔符
【发布时间】:2017-01-23 04:49:58
【问题描述】:

我想在文本输入中使用自动的十进制千位分隔符。 例子 在 textinput 5000 中写入时,我想自动输入 5,000

我有 js:

var cleave = new Cleave('.input-element', {
    numeral: true,
    numeralThousandsGroupStyle: 'thousand'
});

我想用在

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

那么如何在文本输入中使用js呢?

【问题讨论】:

    标签: javascript php yii cleave


    【解决方案1】:

    您可以为您的数字文本字段指定一个特定的类,例如formatted-number-input:

    <td><?= $form->field($model, '$Payment')
                ->textInput(['maxlength' => 15, 'style' => 'width:120px;', 'class' => 'formatted-number-input'])
                ->label(false) ?></td>
    

    你可以在你的javascript代码中使用这个类:

    new Cleave('.formatted-number-input', {
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });
    

    【讨论】:

    • $script = registerJs($script);
    猜你喜欢
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-18
    • 2011-03-12
    • 1970-01-01
    相关资源
    最近更新 更多