How to inhibit PASTE in web app ?

I have a web app which gets the user to enter a phone number. The web form has two text fields

This is double-entered (in two successive fields) to provide some check that the phone number is correct.

How do I inhibit PASTE (Command - V or Control - V) so that the user must type both numbers rather than typing one, copying it, and then pasting into the second field ?

I realise that there may be people who disagree with double entry on philosophical grounds, but for the purposes of this question it would be good to ignore that issue.

Tony Barry

I don’t care if you are cruel to your users. Personally, I am not against double entry, but I dislike very much having to type, since I use a password manager.

It is kind of unusual to apply that to a phone number, and on top of it require typed confirmation. Already providing a phone number is something I usually think hard about. I consider quite a privilege to get my phone. I want to make sure the other party won’t abuse it or sell it.

If on top of it I feel I am not trusted, that is probably the best way for me to enter something like 000-0000 or 123-4567.

Sub Shown() Handles Shown self.ExecuteJavaScript("document.getElementById('"+me.controlId+"').setAttribute('onpaste', 'event.preventDefault();'); ") End Sub

It might be better to stop copy from the two inputs so that incorrectly entered numbers are not transferred but let the user copy in from a good source?

Just change Michel’s example to use oncopy rather than onpaste.

Thank you Michel and Ian ! Top effort.

Tony Barry