You need to sign in to do that
Don't have an account?

count charcters across form
hi,
i need to count the characters from all the fields in visualforce page. currently i am able to count the characters from single field. can anyone help me to count the characters from all fields?
<script>
var i;
function ShowCharCount(myTA, maxSize, SizeLabel) {
i=maxSize-myTA.value.length;
document.getElementById(SizeLabel).innerHTML = 'Word Count: '+ i + ' Characters Left';
i= maxSize;
}
</script>
<apex:inputField value="{!c.name__c}"
onchange="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onmousedown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeyup="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeydown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onclick="ShowCharCount(this, 2000, '{!$Component.myTASize}');" />
<apex:inputTextarea value="{!c.address__c}"
onchange="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onmousedown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeyup="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeydown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onclick="ShowCharCount(this, 2000, '{!$Component.myTASize}');" />
<apex:outputPanel id="myTASize"></apex:outputPanel>
i need to count the characters from all the fields in visualforce page. currently i am able to count the characters from single field. can anyone help me to count the characters from all fields?
<script>
var i;
function ShowCharCount(myTA, maxSize, SizeLabel) {
i=maxSize-myTA.value.length;
document.getElementById(SizeLabel).innerHTML = 'Word Count: '+ i + ' Characters Left';
i= maxSize;
}
</script>
<apex:inputField value="{!c.name__c}"
onchange="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onmousedown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeyup="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeydown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onclick="ShowCharCount(this, 2000, '{!$Component.myTASize}');" />
<apex:inputTextarea value="{!c.address__c}"
onchange="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onmousedown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeyup="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onkeydown="ShowCharCount(this, 2000, '{!$Component.myTASize}');"
onclick="ShowCharCount(this, 2000, '{!$Component.myTASize}');" />
<apex:outputPanel id="myTASize"></apex:outputPanel>
Use this code,
All Answers
You might have to use actionfunction or actionsupport with javascript in visualforce page to dynamically update these integer variables with the legth of the characters of each field.
hope this helps !!
Use this code. This is simpler than the single field,
i want to count characters only from name and billing street only. so how to exclude billing city and billing country from this?
Use this code,
Can we count the character for rich text area fields also? if it is it would be really helpful for us.
--
Thnaks,
Akash