Reputation: 393
Using jquery and texotela inside my form, I have input fields that I want them to allow the user to enter only numric values.
so I added $(".numericInput").numeric({ decimal: false, negative: false});
to them.
My problem is that my inputs also have a function called when the onChange
event is triggered, but after inserting the plugin, the event is not triggered.
How can I allow the user to click only numbers and still have an onChange
event for those inputs ?
Thank's In Advance.
Upvotes: 0
Views: 1852
Reputation: 8520
Looks like texotela is allready listening to onChange and maybe prevents additional handlers. I don't know what you're doing in your onChange but you could use blur
instead which is almost the same.
Blur will fire everytime the input field loses focus, change only if the text also changed.
Upvotes: 1
Reputation: 749
Here is a good plugin to use for masking => https://github.com/RobinHerbots/jquery.inputmask
$(".numericInput").inputmask("integer");
it has a lot of predefined masks and you can use callbacks after a mask is successful or fails for additional criteria or validation.
The reason I like this plugin is the flexibility mentioned above when you have additional events as you mention.
Upvotes: 0