On Saturday 09 December 2006 15:03, Matt Wilson wrote:
> This is probably a trivial problem.  I have a textarea input box in a
> form.  I want to trigger some javasscript code when the user types too
> much into the box.
>
> For example, once the user types 101 characters, I'd like to pop up an
> alert that says "You have typed more than the maximum allowed!"
>
> How can I do this?

You need to attach a function to the input elements onkeyup event, like this:

function validate_input(event) {
  if(event.target().value.length > 100) {
        alert("you typed more than 100 characters");
 }
}

MochiKit.Signal.connect(my_form.elements['elementname'], 'onkeyup', 
validate_input);

But you are aware that the html input controls have a limit property 
themselves, called  "maxlength".

Diez

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to