0

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.

3
  • FWIW - in HTML5, it's just <input type="number"/> Commented May 22, 2013 at 19:42
  • 1
    @Ohgodwhy What is FWIW? Commented May 22, 2013 at 19:46
  • @Vega For What It's Worth Commented May 22, 2013 at 19:48

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

I'm trying to use this plugin but the only problem that each input inside my form have diffrent maxlength number, and for some reason all the inputs become with the maxlength of the first input, even though i see in the source code that the maxlength is not change.. any idea why that happens? I'm using $("#numeric").inputmask("integer");..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.