diff --git a/demo/index.html b/demo/index.html index e1c166d..775c0ee 100644 --- a/demo/index.html +++ b/demo/index.html @@ -72,6 +72,7 @@ leading: '', custom: '', changing: '', + phone: '', pattern: '1111 1111' } }, @@ -112,6 +113,10 @@

<MaskedInputLicense Plate: +
+ + +

Mask placeholder characters can be escaped with a leading \ to use them as static contents:

diff --git a/src/index.jsx b/src/index.jsx index 5b15c6f..45d97be 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -71,6 +71,7 @@ var MaskedInput = React.createClass({ this.mask.selection.end = this.mask.selection.start + sizeDiff this.mask.backspace() } + this.mask.setValue(e.target.value); var value = this._getDisplayValue() e.target.value = value if (value) { @@ -146,6 +147,14 @@ var MaskedInput = React.createClass({ setTimeout(this._updateInputSelection, 0) this.props.onChange(e) } + else { + this.mask.setValue(e.clipboardData.getData('Text')); + var value = this._getDisplayValue() + e.target.value = value + if (value) { + this._updateInputSelection() + } + } }, _getDisplayValue() {