0

i want to decimal thousand separtor with automatic in Text Input. example when write in textinput 5000, i want to automation into 5,000

i have js :

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

and i want to use in

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

so how to use js in text input?

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106

1 Answers1

0

You can give your number text fields a specific class e.g. formatted-number-input:

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

You can use this class in your javascript code:

new Cleave('.formatted-number-input', {
    numeral: true,
    numeralThousandsGroupStyle: 'thousand'
});
topher
  • 14,790
  • 7
  • 54
  • 70