Detecting RightClick->Delete in TextArea

I've got a textarea with a counter showing how many characters are left before you can't type anymore, and functionality truncating to a maximum size if you exceed it.

I've implemented this using onkeyup and onpaste (oninput in Opera, I'm aware of that difference), as well as oncut.

This traps everything except rightclick->delete.  How can I trigger an event based on that so I can toss the same functions at that event?

Please do not suggest jquery or other toolkits/frameworks, it's not going to happen.  I need raw javascript and HTML.

Thanks!
LVL 7
Fairlight2cxAsked:
Who is Participating?
 
Fairlight2cxAuthor Commented:
Well, that's not very complete.  It also actually assumes that it should trigger the detection event as soon as you mouse over the textarea, which is just a plain fallacy in and of itself...you'd miss most pastes because it would have checked before you could hit paste from the context menu.

I settled on a different solution, since I couldn't find an event to handle Delete.  I trigger via oncut/onpaste/oninput/onkeyup, and also have a 250ms setTimeout to check for length changes even when there are no events...which also has the side effect of letting you get status updates while someone is holding down a key with auto-repeat.
0
 
leakim971PluritechnicianCommented:
Hello Fairlight2cx,

Try this :

If you past more than two chars, an alert box appear
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	function rightClick(e) {
		ta = document.getElementById("ta");
		if(ta.value.length>2) {
			alert("More than two char");
			ta.value = ""; 
		}
	}
</script>
</head>
<body >
<textarea id="ta" cols="128" rows="16" onmousemove="rightClick()"></textarea>
</body>
</html>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.