As when you insert the phone into the mask using ctrl-v to delete the first character?

There's a mask that adequately inserted numbers like +7 (834) 523-0654, but the rooms 88345230654 be inserted does not want, and there is the first number inserted after +7 and the last number is cut off.
Is it possible before Ctrl-V to trim a string from the clipboard?
June 14th 19 at 18:28
1 answer
June 14th 19 at 18:30
Solution
Cut the beforepaste event
This event does not want to work in React - Tierra_Wolff commented on June 14th 19 at 18:33
Works https://stackoverflow.com/questions/32814363/how-t... - sherwood31 commented on June 14th 19 at 18:36
but it onPaste and onBeforePaste not - Tierra_Wolff commented on June 14th 19 at 18:39
accordingly it is necessary to cancel the default behavior is to do with the data what you want, and manually insert them to value your input.

I.e. inside the handler will be something like this
onPaste: function(e) {
 e.preventDefault(); // Cancels the default behavior
 // Then further manipulation to transform the data and insert them in the input
},
- sherwood31 commented on June 14th 19 at 18:42
If suddenly someone will need to have done something like this:
handleBeforePaste(event){
 const target = event.target
event.clipboardData.items[0].getAsString(text=>{
event.preventDefault()

 if(this.props.disabled) return
 const countNum = String(Math.abs(text)).length
 countNum == 11 ? text = text.slice(1) : false

 this.props.onChange(text, target, this.props.position)
})
 }
- Tierra_Wolff commented on June 14th 19 at 18:45

Find more questions by tags JavaScriptReactRegular expressions