Tempus-dominus: onchange event is not working on input field

Created on 6 Mar 2017  路  4Comments  路  Source: Eonasdan/tempus-dominus

<input type='text' onchange='javascript:alert()' name="mypicker"/>
onchange event is not triggering. I mean, when I change I need to call a function from html tag.

Most helpful comment

Same for me, I wanted to use the options "keepInvalid" and "useStrict" to warn the user instead of overwriting its input, but I failed when trying

$('input[name=mypicker]').on('change', onDateChanged);

BUT there is another event triggered by the datetimepicker : dp.change
So you can do

$('input[name=mypicker]').on('dp.change', onDateChanged);

It doesn't trigger a "real" event though, it's a custom one, but you still can catch it to know the input changed

All 4 comments

Do you solve the problem yet? I also hit this problem.

Same for me, I wanted to use the options "keepInvalid" and "useStrict" to warn the user instead of overwriting its input, but I failed when trying

$('input[name=mypicker]').on('change', onDateChanged);

BUT there is another event triggered by the datetimepicker : dp.change
So you can do

$('input[name=mypicker]').on('dp.change', onDateChanged);

It doesn't trigger a "real" event though, it's a custom one, but you still can catch it to know the input changed

Hi, I鈥檒l be closing issues that have been answered by the community.

The issue with dp.change versus change is that the former is forcing your code (e.g. validation) to be aware of the date picker used. It's not clear from https://getdatepicker.com/4/Events/#dpchange why the custom event was needed or what are its benefits over the standard change event.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

callum-resdiary picture callum-resdiary  路  4Comments

am11 picture am11  路  6Comments

benbhale picture benbhale  路  5Comments

illudens picture illudens  路  4Comments

dleffler picture dleffler  路  4Comments