barantamer
01-20-2009, 08:26 AM
hello i am trying to restrict the number of characters to be entered to textarea in my jsf page on the client side
i am trying to use the codes below
<SCRIPT LANGUAGE="JavaScript">
// function parameters are: field - the string field, count - the field for remaining characters number and max - the maximum number of characters
function CountLeft(field, count, max) {
// if the length of the string in the input field is greater than the max value, trim it
if (field.value.length > max)
field.value = field.value.substring(0, max);
else
// calculate the remaining characters
count.value = max - field.value.length;
}
</script>
<h:inputTextarea onkeyup="CountLeft(this.form.txtAreaStream,this.form.left,50);" onkeydown="CountLeft(this.form.txtAreaStream,this.form.left,50);" id="txtAreaStream" cols="50" rows="10" required="true" >
Actually i have found the problem but i do not know how to solve it since i am new to jsf
The HTML output is
<textarea name="j_id_jsp_1552126572_1:txtAreaStream" id="j_id_jsp_1552126572_1:txtAreaStream" cols="50" rows="10" onkeydown="CountLeft(this.form.txtAreaStream,this.form.left,50);" onkeyup="CountLeft(this.form.txtAreaStream,this.form.left,50);"></textarea>
the name of the text area is changes. How can i solve this problem?
Thanks in advance
i am trying to use the codes below
<SCRIPT LANGUAGE="JavaScript">
// function parameters are: field - the string field, count - the field for remaining characters number and max - the maximum number of characters
function CountLeft(field, count, max) {
// if the length of the string in the input field is greater than the max value, trim it
if (field.value.length > max)
field.value = field.value.substring(0, max);
else
// calculate the remaining characters
count.value = max - field.value.length;
}
</script>
<h:inputTextarea onkeyup="CountLeft(this.form.txtAreaStream,this.form.left,50);" onkeydown="CountLeft(this.form.txtAreaStream,this.form.left,50);" id="txtAreaStream" cols="50" rows="10" required="true" >
Actually i have found the problem but i do not know how to solve it since i am new to jsf
The HTML output is
<textarea name="j_id_jsp_1552126572_1:txtAreaStream" id="j_id_jsp_1552126572_1:txtAreaStream" cols="50" rows="10" onkeydown="CountLeft(this.form.txtAreaStream,this.form.left,50);" onkeyup="CountLeft(this.form.txtAreaStream,this.form.left,50);"></textarea>
the name of the text area is changes. How can i solve this problem?
Thanks in advance