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.
– LeAndrade
Is there any simple way to verify this?
– Otavio Souza Rocha
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.
– LeAndrade
Got it.. so I think I’d better use a React component to put the masks on. Thanks
– Otavio Souza Rocha
Use a pure JS mask: https://answall.com/a/280783/8063
– Sam
Use this mask that the DVD made, will serve there for you.
– LeAndrade
Thanks @dvd, I’m in another project more urgent now, but as soon as I finish I already test this solution
– Otavio Souza Rocha
Quiet. QQ thing just call.
– Sam
@dvd worked that is a beauty!!! I just had to change the format of the phone to have DDD, but it came practically ready
– Otavio Souza Rocha
Cool. Success right there.
– Sam
Post an answer to how you did it if it fits someone in the future.
– Sam
I posted on the topic you created en.stackoverflow.com/a/280783/8063
– Otavio Souza Rocha