In this Example i am Describing , Paste only numbers or numeric in the text box..
here if we copying characters + numbers it will paste (display) only Numbers
Here is the Example
1)First Copy Any data:
2)Paste in second text box
3)final OUTPUT:
Text box onpaste :
------------
onpaste="return paste(this);"
Script:
-------
function paste(obj) {
var totalCharacterCount = window.clipboardData.getData('Text');
var strValidChars = "0123456789";
var strChar;
var FilteredChars = "";
for (i = 0; i < totalCharacterCount.length; i++) {
strChar = totalCharacterCount.charAt(i);
if (strValidChars.indexOf(strChar) != -1) {
FilteredChars = FilteredChars + strChar;
}
}
obj.value = FilteredChars;
return false;
}
good....Thnxs
ReplyDeleteI was spend my time in saerching in google
ReplyDeletethanks a lot
This code works fine in Internet explorer,but its not working in chrome
ReplyDeleteIt is very good blog and useful for students and developer , Thanks for sharing
ReplyDeleteDot Net Online Training Bangalore