Need to use `onkeypress`, `onkeydown`, or `onkeyup` to get value
Closed this issue · 2 comments
biladina commented
Steps to reproduce the issue
- install most recent Yii2 version
- install most recent Number Control
Expected behavior and actual behavior
expected behavior : I can use onkeypress
, onkeydown
, or onkeyup
to get value..
actual behavior : I can only use onchange
to get value..
Environment
Browsers
- Google Chrome
- Mozilla Firefox
Operating System
- Windows
- Linux
Libraries
- jQuery version : 3.5.1
- yii2-number version : 1.0.5
- yii2 version : 2.0.40
Isolating the problem
- This bug happens on the docs and demos page
- The bug happens consistently across all tested browsers
- This bug happens when using yii2-number without other plugins.
this is my code :
<?= $form->field($target, "[$index]anggaran")->widget(NumberControl::classname(), [
'maskedInputOptions' => [
'prefix' => 'Rp. ',
'groupSeparator' => '.',
'radixPoint' => ',',
'allowMinus' => false,
'digits' => 1000,
],
'options' => ['onkeypress' => 'kalkulasiAnggaran()'],
'displayOptions' => ['class' => 'form-control kv-monospace'],
])->label(false) ?>
and this is my Javascript function :
function kalkulasiAnggaran()
{
var total_anggaran = 0;
total_anggaran = parseFloat($("#anggaran").val());
console.log(total_anggaran.toFixed(2));
}
I need to use onkeypress
, onkeydown
, or onkeyup
, but this extension only allowed onchange
..
biladina commented
if you guys need it, I already solve it, not the ideal way, but it works..
https://stackoverflow.com/questions/68128833/kartik-yii2-number-getting-value-from-extension/
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.