Read the Text from clipboard and validate using ValidateText Function.
function OnTextPaste()
{
var data="";
data=window.clipboardData.getData("Text");
if(data)
{
var ret=ValidateText(data);
if(!ret)
alert('Sorry, you can not paste text having <, > in it.');
return ret;
}
else
return false;
}
function ValidateText(str)
{
var ret;
if(str.indexOf('<') != -1)
ret=false;
else if(str.indexOf('>') != -1)
ret=false;
else
ret=true;
return ret;
}
0 comments:
Post a Comment