Disabling paste on an input field February 14, 2013Posted by Duncan in PeopleTools.
A colleague of mine recently had a requirement to place an email address field on a page, and then just below it a ‘confirm email address’ – however the user should not be permitted to copy and paste from the first field to the second, they should retype their email address.
1) Place the two input fields on the page and connect them to the records you wish to save to, as usual.
2) Place an HTML Area on the page, making sure it’s beneath the other fields (both on this screen and the order tab).
3) Make the HTML Area contents static, and paste in the following:
var message = "Paste disabled. Please re-key.";
4) Swap DERIVED_TEST_TEXT2 in the above code snippet for you Record/Field name (i.e. it’s the record name, then an underscore, then the fieldname. Look in View Source or Chrome Dev Tools/Firebug if you’re not sure.)
5) You might also want to make the alert message a little more user friendly too.