onChange on jQuery Input Mask does not work

Asked

Viewed 375 times

0

I have an React component for user registration, in some of the fields I added a Jquery mask, but since I added the mask, the onChange command stopped working (only in the fields with the mask)

one of the fields is this:

<input type="text" className="form-control nascimento-cliente" id="nascimento"  name="nascimento" onChange = {(event) => this.onChange(event.target) } />

The function that onChange is calling:

onChange(target) {
    const change = {};
    change[target.name] = target.value;
    this.setState(change);
}

If I remove the mask everything works, but in some fields the mask is essential

  • Probably giving some Js conflict in the script.

  • Is there any simple way to verify this?

  • 1

    If on the console showing nothing, face will be quite difficult to figure out, this is a big problem with these new frameworks of Js like Angular, React etc... For you to be able to use jQuery with these frameworks without giving any kind of conflict is quite complicated, so even, the staff recommends do not use jQuery.

  • Got it.. so I think I’d better use a React component to put the masks on. Thanks

  • 1

    Use a pure JS mask: https://answall.com/a/280783/8063

  • Use this mask that the DVD made, will serve there for you.

  • Thanks @dvd, I’m in another project more urgent now, but as soon as I finish I already test this solution

  • Quiet. QQ thing just call.

  • @dvd worked that is a beauty!!! I just had to change the format of the phone to have DDD, but it came practically ready

  • Cool. Success right there.

  • 1

    Post an answer to how you did it if it fits someone in the future.

  • I posted on the topic you created en.stackoverflow.com/a/280783/8063

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.