• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to limit a text area in RSForm [SOLVED]

How to limit a text area in RSForm [SOLVED] 17 years 4 days ago #2910

Ok, I got it working!
First, I used a different snippet of javascript, just because I liked this one better:
www.mediacollege.com/internet/javascript...imit-characters.html

#1) So copy this code into a file called limit.js
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

Save the limit.js file somewhere on your server.

#2) Create your form and the text area field you want

#3) While editing the text area field, add this code to the Additional Attributes field:
onKeyDown=\"limitText(this.form['form[Fieldname]'],this.form.countdown,1500);\" onKeyUp=\"limitText(this.form['form[Fieldname]'],this.form.countdown,1500);\"

In this case, replace Fieldname with the name of your field.

#4) In the field style, add this somewhere below the {field}:
<br />
<font size=\"1\">(Maximum characters: 1500)<br>
You have <input readonly type=\"text\" name=\"countdown\" size=\"3\" value=\"1500\"> characters left.</font>

#5) Save your field and add this code to the scripts tab for your form under \"Script called on form display\" --
$doc = &JFactory::getDocument();
$doc->addScript('/path-to-your-script-/limit.js');

#6) Save the form and that's it!

When a user types, they will be limited to 1500 characters and the form will tell them how many characters they have left.

Post edited by: tomgreever, at: 2008/05/09 00:48<br><br>Post edited by: tomgreever, at: 2008/05/09 00:49
The administrator has disabled public write access.

Re:How to limit a text area in RSForm [SOLVED] 16 years 8 months ago #4617

  • Geday
  • Geday's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
I know this was asked in some earlier posts but can you achieve the same thing for words instead of characters?
The administrator has disabled public write access.

Re:How to limit a text area in RSForm [SOLVED] 16 years 3 months ago #6333

Followed your solution but get this error :
Fatal error: Class 'JFactory' not found in /home/site_namel/public_html/components/com_rsform/controller/functions.php(879) : eval()'d code on line 1

I am running RSform Pro version 1.1.0 rev 19 on Joomla 1.0.15
The administrator has disabled public write access.

Re:How to limit a text area in RSForm [SOLVED] 14 years 9 months ago #10976

Hello,

thanks for your script.

I succeded to make it work for one textarea, but when you want to apply the coutdown on other textareas, it's not working anymore.

I am been changing the name of the fields but either ...

Do you have any idea ?

Cheers

Yvan
The administrator has disabled public write access.

Re:How to limit a text area in RSForm [SOLVED] 14 years 2 months ago #12997

  • Flash
  • Flash's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
It's been a while since the last post was made in this topic, but I need some help regarding this script.

I did everything that was posted in the first post, but someone I get this error:

Parse error: syntax error, unexpected ';', expecting T_PAAMAYIM_NEKUDOTAYIM in C: \ domains \ website \ wwwroot \administrator \ components \ com_rsform \ helpers \rsform.php(1099) : eval()'d code on line 1

After I put this in the script part of the form:

$doc = &amp;JFactory::getDocument(); 
$doc-&gt;addScript('/limit.js');
Last Edit: 14 years 2 months ago by Flash.
The administrator has disabled public write access.

Re:How to limit a text area in RSForm [SOLVED] 14 years 2 months ago #13005

  • Flash
  • Flash's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Anyone?
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!