File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,12 @@ <h1><code><<a href="https://github.com/insin/react-maskedinput">MaskedInput</
9292 < p className = "lead" > A React component which creates a masked < code > <input/></ code > </ p >
9393 < div className = "form-field" >
9494 < label htmlFor = "card" > Card Number:</ label >
95- < MaskedInput mask = "1111 1111 1111 1111" name = "card" id = "card" size = "20" onChange = { this . _onChange } />
95+ < MaskedInput mask = "1111 1111 1111 1111" name = "card" id = "card" size = "20" value = { this . state . card } onChange = { this . _onChange } />
96+ </ div >
97+ < p > You can even externally update the card state like a standard input element:</ p >
98+ < div className = "form-field" >
99+ < label htmlFor = "card" > Externally Update:</ label >
100+ < input onChange = { this . _onChange } name = "card" maxLength = "16" style = { { borderBottom : '1px solid #999' } } />
96101 </ div >
97102 < p > Placeholders are automatically generated but can be overridden with your own:</ p >
98103 < div className = "form-field" >
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ var MaskedInput = React.createClass({
4343 } ,
4444
4545 componentWillReceiveProps ( nextProps ) {
46+ if ( this . props . value !== nextProps . value ) {
47+ this . mask . setValue ( nextProps . value )
48+ }
4649 if ( this . props . mask !== nextProps . mask ) {
4750 this . mask . setPattern ( nextProps . mask , { value : this . mask . getRawValue ( ) } )
4851 }
You can’t perform that action at this time.
0 commit comments