Skip to content

Instantly share code, notes, and snippets.

@krescruz
Created December 20, 2017 16:51
Show Gist options
  • Save krescruz/4b3efc559db2993d2db0a2aa8c282159 to your computer and use it in GitHub Desktop.
Save krescruz/4b3efc559db2993d2db0a2aa8c282159 to your computer and use it in GitHub Desktop.
React masked input
import React, { Component } from 'react'
import MaskedInputBase from 'react-maskedinput'
class MaskedInput extends Component {
getValue() {
const value = this.refs.masked.mask.getRawValue()
return value.replace(/[\s,_]/g, '')
}
render() {
return <MaskedInputBase { ...this.props } ref='masked' />
}
}
export default MaskedInput
@krescruz
Copy link
Author

Get the final value of a mask input
Example: this.refs.myinput.getValue()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment