In this Example i am Describing , Copy only numbers or numeric characters in the text box..
here if we copy characters + numbers it will copy only Numbers
Here is the Example :
1)Copy data from Textbox :
2) Paste in another Textbox :
3) Final OUTPUT :
TextBox oncopy :
oncopy="return CopyNumericOnly(this);"
Script :
function CopyNumericOnly(obj) {
var textboxvalue = obj.value;
var strValidChars = "0123456789";
var strChar;
var FilteredChars = "";
for (d = 0; d < textboxvalue.length; d++) {
strChar = textboxvalue.charAt(d);
if (strValidChars.indexOf(strChar) != -1) {
FilteredChars = FilteredChars + strChar;
}
}
window.clipboardData.setData('Text', FilteredChars);
return false;
}
here if we copy characters + numbers it will copy only Numbers
Here is the Example :
1)Copy data from Textbox :
2) Paste in another Textbox :
3) Final OUTPUT :
TextBox oncopy :
oncopy="return CopyNumericOnly(this);"
Script :
function CopyNumericOnly(obj) {
var textboxvalue = obj.value;
var strValidChars = "0123456789";
var strChar;
var FilteredChars = "";
for (d = 0; d < textboxvalue.length; d++) {
strChar = textboxvalue.charAt(d);
if (strValidChars.indexOf(strChar) != -1) {
FilteredChars = FilteredChars + strChar;
}
}
window.clipboardData.setData('Text', FilteredChars);
return false;
}
gud maneel,all d best
ReplyDeleteThanks dear...
Delete