sanniassin / react-input-mask

Input masking component for React. Made with attention to UX.
MIT License
2.22k stars 258 forks source link

How set focus on InputMask element? #207

Open solo-framework opened 4 years ago

solo-framework commented 4 years ago

Could you show me an example how to set focus on masked input text? I treid autoFocus={true} but it doesn't work

jrmarqueshd commented 4 years ago

For me it worked simply by adding autoFocus directly to the , but you can also test it this way: this.inputRef.getInputDOMNode().focus();.

Credits by @duhwcarvalho

compwright commented 3 years ago

This is documented: https://github.com/sanniassin/react-input-mask/tree/v2#inputref--function

cristoferrao commented 1 year ago

I got solution by using javascript html passing id and try { window.document.getElementById("expiryDtId").focus(); } catch (error) { console.error(error); } works for me