Copy link to clipboard
Copied
Hi,
I'm using CF8 and this is my code
<cftextarea id="summary" name="summary" rows="5" cols="80" maxlength="300" required="yes" validate="noblanks" message="You must enter summary." />
It is not working. Am I doing anything wrong?
Thanks
Joe Green
function limitText1(limitField, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); alert("Character limit exceeded - please reduce the length of description."); } } and onKeyDown="limitText1(this.form.summary,300); Works finally.
Copy link to clipboard
Copied
What do you mean by 'not working'? Does nothing appear? Are you able to type in more than 300 characters? Do you get a javascript error? ... etc
Copy link to clipboard
Copied
Hi Joe,
Can you be more specifc about this issue, what is it that not woking and is it not validating the maxlength.
Try and use validate="maxlength"
Thanks,
Priyank
Copy link to clipboard
Copied
Yes now it is working with validate="maxlength".
Is there a way to stop user from typing more characters than say 300 or show char counter?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
maxlength="300" is not enough because user can keeping on typing over the 300 limit. That's why I'm wondering if there is any way we can disable keys after 300 character limit has reached or display the number of charaters typed.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This script doesn't work with cftextarea. Got a love Coldfusion.
Copy link to clipboard
Copied
function limitText1(limitField, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); alert("Character limit exceeded - please reduce the length of description."); } } and onKeyDown="limitText1(this.form.summary,300); Works finally.