Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  173] [ 5]  / answers: 1 / hits: 23289  / 15 Years ago, fri, july 3, 2009, 12:00:00

how do I prevent the user to change the value in an input field (which contains a certain value to be copied into the clipboard) without using disabled=true? The text should be selected once the user clicks in the field (that's working already) but entering anything should have no effect.



Thanks



jQuery('input.autoselect[value]').focus(function() { jQuery(this).select(); });

More From » jquery

 Answers
77

readonly in the html of the input is all you need to prevent the user from editing the input.



<input readonly=readonly type=text value=You can't edit me!/>

[#99196] Sunday, June 28, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tiffany

Total Points: 46
Total Questions: 97
Total Answers: 84

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;