[Pro] php feedbackform word number limit

Hi there, maybe I missed something, but I use the php feedbackform and wonder how I can achieve an upper limit of words that can be filled in a textarea. I would love to simply have 100 words more or less. I want to block the insert of more.

Any Ideas? Thanks a lot,…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

A textarea cannot be limited within HTML the way that a text input
can, but you can simulate this with JavaScript pretty easily. You can
even provide a count-down indicator that tells the user how many words
remain for their manifesto.

If you apply Protaculous to your page, you can do it in a couple of
lines of code, if you write your JavaScript long-hand, you will need
to spend more time on plumbing and on ensuring a cross-browser event
model.

Apply Protaculous to your page, click on the bottom Function Body
button and paste in the following (after making sure that you note the
name of your textarea as reported on the Output tab of the Inspector).

// assuming here your textarea is called 'message'
var m = $$('textarea[name="message"]').first();
m.observe('keydown',function(evt){
	if(($F(m).split(/s/g).length)  > 100) evt.stop();
});

If you wanted to provide feedback, then you could add a text field to
the page, call it countdown in the output tab of the Inspector, and
make your function body look like this instead:

var m = $$('textarea[name="message"]').first();
var c = $$('input[name="countdown"]').first();
var limit = 100;
c.setValue(limit);
m.observe('keydown',function(evt){
	var now = $F(m).split(/s/g).length;
	if(now > limit){
		evt.stop();
	}else{
		c.setValue(limit - now)
	}
});

Neither of these approaches can do anything about someone pasting a
million lines of text into the field, but it is a start.

Walter

On Dec 2, 2009, at 4:01 AM, sonjanna wrote:

Hi there, maybe I missed something, but I use the php feedbackform
and wonder how I can achieve an upper limit of words that can be
filled in a textarea. I would love to simply have 100 words more or
less. I want to block the insert of more.

Any Ideas? Thanks a lot,…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thank you very much Walter.
I `ll try this out and post a Feedback as soon as possible.
All the best!


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options