Form with onSubmit event and Submit URL

notorious.madeye 23 Mar, 2013
Hi,

I started evaluating ChronoForms for our company and have got trouble getting it to work. I'm using Joomla 2.5 and ChronoFormsV4. The install was a piece of cake and everythings fine. Now I started converting an existing form from our old website to ChronoForms. This is where the trouble starts. My old form looks like this:

<form class="myform" name="myform" action="https://urltocall/redirect.php" method="post" onsubmit="execute js code;">

I want to use the onSubmit event because there I can check the captcha, which is needed to save my form from spambots. What I did was placing a ReDirect URL event after my captcha verification and after the ReDirect URL event I placed a Custom Code event to run my JavaScript. That's how I implemented it after searching this forum for similar posts. The problem is that I don't get it running.
Can anybody explain to me what I'm doing wrong?
GreyHead 24 Mar, 2013
Hi notorious.madeye,

If you just want to add the JavaScript to the <form> tag then you can do that in the Form Tag attachments box on the form General tab (click the form name link in the Forms Manager to see it).

It's better practice to separate out the JavaScript from the HTML, you can use the form onSubmit event or the Submit button events to do that and add your script in a Load JS action. Please see this FAQ. Note that the form validation also fires of the submit events and may conflict with your code; there is a validation onSuccess event that you can use if that is a problem.

If you are using JavaScript for a Captcha, that will be of limited value as many of the spambots run with JavaScript off. To protect from them there are several options in ChronoForms. Please see this FAQ

You say that you are using a Custom Code action after the ReDirect URL to load your JavaScript. Presumably this is in the On Submit event of the form and usually this runs on the server and so JavaScript won't run; you need to add JavaScript to the On Load event so that it can run in the browser.

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