hi
I use below code to count textbox's characters and display in label:
<script type="text/javascript">
$(function () {
var i = 0;
$('[id*=Txtmatn]').keydown(function (e) {
var ctrlKey = 67, vKey = 86;
if (e.keyCode != ctrlKey && e.keyCode != vKey) {
$('[id*=hfCharacterCount]').val(toPersianNumber($(this).val().length));
$('[id*=LbltedaCh]').html($('[id*=hfCharacterCount]').val());
$('[id*=hfTextBoxValue]').val($(this).val());
if ($(this).val().length % 70 == 0) {
i = $(this).val().length / 70;
i = toPersianNumber(i);
$('[id*=hfMessageCount]').val(i);
$('.MessageCount').html($('[id*=hfMessageCount]').val());
}
else {
i = $(this).val().length / 70;
i = toPersianNumber(parseInt(i));
$('[id*=hfMessageCount]').val(i);
$('.MessageCount').html($('[id*=hfMessageCount]').val());
}
}
});
$('[id*=Txtmatn]').keyup(function (e) {
var ctrlKey = 67, vKey = 86;
if (e.keyCode != ctrlKey && e.keyCode != vKey) {
$('[id*=hfCharacterCount]').val(toPersianNumber($(this).val().length));
$('[id*=LbltedaCh]').html($('[id*=hfCharacterCount]').val());
$('[id*=hfTextBoxValue]').val($(this).val());
if ($(this).val().length % 70 == 0) {
i = $(this).val().length / 70;
i = toPersianNumber(i);
$('[id*=hfMessageCount]').val(i);
$('.MessageCount').html($('[id*=hfMessageCount]').val());
}
else {
i = $(this).val().length / 70;
i = toPersianNumber(parseInt(i));
$('[id*=hfMessageCount]').val(i);
$('.MessageCount').html($('[id*=hfMessageCount]').val());
}
}
});
$("[id*=Txtmatn]").bind('paste', function (e) {
setTimeout(function () {
$('[id*=hfCharacterCount]').val(toPersianNumber($("[id*=Txtmatn]").val().length));
$('[id*=LbltedaCh]').html($('[id*=hfCharacterCount]').val());
$('[id*=hfTextBoxValue]').val($("[id*=Txtmatn]").val());
var msgCount = $("[id*=Txtmatn]").val().length / 70;
msgCount = toPersianNumber(Math.floor(msgCount));
$('[id*=hfMessageCount]').val(msgCount);
$('.MessageCount').html($('[id*=hfMessageCount]').val());
}, 100);
});
});
function toPersianNumber(input) {
var inputstring = input;
var persian = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"]
for (var j = 0; j < persian.length; j++) {
inputstring = inputstring.toString().replace(new RegExp(j, "g"), persian[j]);
}
return inputstring;
}
</script>
here it will display count of character into Lbltedach
and count of message in Lblcount class:MessageCount
now I define 2 other lable 1-LblNumber 2-LblSum
that I want when users type into textbox when it count charcter and show messgaecount into Lblcount it do:
LblNumber*Lblcount and display in LblSum
i.e
Number count:5 --->(this is LblNumber)
Character count: 155
Number of message:2 --->(this is LblCount)
LblSum=10 ---->(lblNumber* lblcount)
how I can do it?
Best regards
neda