I've got a popup box which allows a user to type a brief (50 character) note. What I need to do is figure out how to prevent the user from copy/pasting a note using the right mouse click.
I looked up all the events available for a textbox, and onkeyup and onkeydown are not in this list but they do have an effect.
I have the following JavaScript that captures keystrokes:
<!--//**********************************
// Comment Character Count
//********************************** -->
<script type="text/javascript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
</script>
And then this textbox which calls the above function when a key is pressed:
<asp:TextBox ID="txtCommentBox" TextMode="MultiLine" CssClass="textbox" Wrap="True"
Height="70px" Width="270px" Font-Size="Small" Rows="3" runat="server"
onkeyup="textCounter(this, this.form.remLen, 50);"
onkeydown="textCounter(this, this.form.remLen, 50);" />
Everything works awesome, except when someone right-clicks and chooses "Paste", it bypasses the check because no keys are pressed. Any ideas on how to trap for that? Is there an undocumented onmouseclick event I can call or something?