i have two nested datalist and there are two txtbox inside the two, now i want to write a javascript code to limit number of text insertd into but textbox, but my javascript cant find the two txtbox, see error below
Compiler Error Message: CS0103: The name 'txtcommentpost' does not exist in the current context
Source Error:
Line 4191:
Line 4192: if (document.getElementById('<%= TextBixcomment.ClientID %>')) {
Line 4193: var ctrl = document.getElementById('<%= txtcommentpost.ClientID %>');
Line 4194: var len = document.getElementById('<%= txtcommentpost.ClientID %>').value.length;
Line 4195: if (len <= maxSize) {
see javascript below
<script type="text/javascript">
function CountCharacters() {
var maxSize = 500;
if (document.getElementById('<%= TextBixcomment.ClientID %>')) {
var ctrl = document.getElementById('<%= txtcommentpost.ClientID %>');
var len = document.getElementById('<%= txtcommentpost.ClientID %>').value.length;
if (len <= maxSize) {
var diff = parseInt(maxSize) - parseInt(len);
if (document.getElementById('<%= txtRemain2.ClientID %>')) {
document.getElementById('<%= txtRemain2.ClientID %>').value = diff;
}
}
else {
ctrl.value = ctrl.value.substring(0, maxSize);
}
}
return false;
}
</script>
<script type="text/javascript">
function CountCharacters() {
var maxSize = 500;
if (document.getElementById('<%= TextBixcomment.ClientID %>')) {
var ctrl = document.getElementById('<%= txtcommentpost2.ClientID %>');
var len = document.getElementById('<%= txtcommentpost2.ClientID %>').value.length;
if (len <= maxSize) {
var diff = parseInt(maxSize) - parseInt(len);
if (document.getElementById('<%= txtRemain3.ClientID %>')) {
document.getElementById('<%= txtRemain3.ClientID %>').value = diff;
}
}
else {
ctrl.value = ctrl.value.substring(0, maxSize);
}
}
return false;
}
</script>