insin / inputmask-core

Standalone input mask implementation, independent of any GUI
MIT License
304 stars 52 forks source link

How to clear a field? #7

Open lgsanjos opened 9 years ago

lgsanjos commented 9 years ago

After submitting a form I'd like to clear the data.

Usually this should be enough

this.refs.requestForm.getDOMNode().reset();

But didn't work, also I tried

React.findDOMNode(this.refs.phone).value = '';

Both ways work for common inputs, but no luck with inputmask. Any suggestion ?

Dzeinz commented 7 years ago

Late to comment on this but I found the solution.

If you use ref on a MaskedInput, you need to call: this.refs.<YOUR REF NAME>.input to access values or reset.

this.refs.requestForm.input.getDOMNode().reset(); should work for your case