Issues with javascript in custom code element

luxhodge 02 Dec, 2013
Has anyone seen the following happen: I add javascript in an action in the event tab and a call to the javascript function in a custom code element on the front side of the form. When I add the function call to the form element (in this case it is a onchange="myFunction();" call) and save the form, a "-" is added between on and change so that it is now on-change. This faults my script. Likewise, on the JS action I add to the back side of the form, it adds a "-" between the on and load that I am using to initialize my javascript elements. Why is it doing this? I have the site editor set to none and I have pure code checked in the custom code box on the front side of the form. I am running chronoforms version 4.01 and Joomla! v3.1. Any ideas? Thank you!

Erik
luxhodge 02 Dec, 2013
Sorry to waste anyone's time. The issue was with RS Firewall. It is a great component, but it is difficult to work with if you use javascript. I uninstalled it for now. The javascript is back working. I will test it on the development site and see how to configure it to work with Chronoforms. I will post the results here when I figure out what needs to be done to work around it.
GreyHead 02 Dec, 2013
Hi Erik,

Thanks for the update, I would not have thought of that as a possible answer. I guess that it automatically edits valid event names to prevent possible hacking. The answer may be to avoid function names like onXxx()

Bob
luxhodge 14 Jan, 2014
RSFirewall update: I added an exception for the chronoforms component in the firewall exception list. This is not ideal, but I added more server side validation to the forms as well to try to protect against bad code injections. I will post any more updates I have on this component as I live with it every day.
GreyHead 14 Jan, 2014
Answer
Hi Erik,

It might also help if you don't add the event calls to the inputs but use the MooTools addEvent() method.
window.addEvnet('domready', function() {
  $('input_id').addEvent('click', function(){
    // some script
  });
  // or 
  $('input_id').addEvent('blur', some_function);
});

Bob
luxhodge 15 Jan, 2014
Thanks for the tip Bob!

I will give that a try when I get a chance and post the results here.

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