Upgraded and now code is not working ...

bobjones 30 Jul, 2010
Hello. I had been using an old version of ChronoForms on an old version of Joomla. I finally had some time and installed a new version of Joomla with the latest version of ChronoForms. I re-created my form and everything works great except for one bit of code that I had in my old form which limited the number of characters that I was allowing in a textarea. My old code was:

  <p><b>4. Enter your message below: </b> <font size="2">(limited to 2000 characters)</font><br>   <textarea name="body" rows=10 cols=40  onKeyDown="messageLength(this.form.body,this.form._charsleft,2000)"  onKeyUp="messageLength(this.form.body,this.form._charsleft,2000)"  class=editSupportVariables></textarea><br>

Message limit 2000 characters. 
<input type=text  name="_charsleft" value="2000" width=4 style="font-size: 10px; width: 40px; height: 16px;  padding-top: 0px; padding-bottom: 0px; text-align: center" size="20">
 characters left


Is there a tweak to this code that I can make so it works in the newest version of ChronoForms? Or even a whole different code that I can use -- I am not married to this code.

Thank you!
nml375 30 Jul, 2010
Hi bobjones,
Generally, inline events don't work well with the Event-model of LiveValidation and MooTools used by recent Chronoforms. It is recommended that you use the addEvent() method of the Element class:
window.addEvent('domready', function() {
  $('input').addEvent('keydown', function(e) {
    event = new Event(e);
    ... rest of code here, event.target points to the element where the event was triggered ..
  });
  $('input').addEvent('keyup', function(e) {
    ....
  });
});

The code above uses the short $() function from MooTools, which is roughly equivalent with getElementById(), and assumes that the input has the id 'input'.

The domready event is used to add the other events only once the whole page has been loaded.

/Fredrik
This topic is locked and no more replies can be posted.