Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve data from clipboard

Status
Not open for further replies.

jabari78

Programmer
Feb 27, 2004
1
US
I have an input field. Let's say that someone has copied some text from elsewhere and wish to paste this in my input field. Is there a way to fint out what is currently in the clipboard before it is pasted? If so, please share the solution.

Thanks!
 
Sorry I cant help you - but would you be able to post the javascript code for a button in a form that would paste the clipboard text into the textarea in that form
thanks
 
AFAIK yes, at least under IE5 and higher:

Code:
<input type="text" onpaste="return checkClipboard()">
...
<script language="javascript">
function checkClipboard()
{	var forbidden_word = "phuck";

	blah = window.clipboardData.getData("Text");
	bValid = (blah.indexOf(forbidden_word)== -1)
	if (!bValid)	alert( "I'm sorry Dave. I can't do that" );

	return bValid;
}
</script>
 

You think HAL was programmed in Javascript?

Or maybe JScript, which is why he turned bad in the end? *grin*

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top