Hi,
Joomla 2.5.17 with chronoforms 4.0.1.
I have have a 4 page single form. Right now I am using Number validation of fields on the third page, but I need to change some of the fields to have a custom currency validation routine.
So, what I did was add a Load JS event before the Show HTML on the third page. I changed the class to: validate['required', '%currency'] for the form field and unchecked the required box on the validation tab.
In the Load JS event I added the following code:
How do I get a custom validation routine to work on multi-page forms?
Thank you.
The alert "currency validate" never displays in the frontend. When you submit that page, the second field is validated that has Number validate, but the first field is now skipped.
Joomla 2.5.17 with chronoforms 4.0.1.
I have have a 4 page single form. Right now I am using Number validation of fields on the third page, but I need to change some of the fields to have a custom currency validation routine.
So, what I did was add a Load JS event before the Show HTML on the third page. I changed the class to: validate['required', '%currency'] for the form field and unchecked the required box on the validation tab.
In the Load JS event I added the following code:
window.addEvent('domready', function(){
function currency(el) {
alert("currency validate");
/* Check for default value first */
if (el.value == 'eg. $30,000,000') {
el.errors.push("<?php echo 'Please enter a valid currency amount' ?>");
return false;
} else {
/* check for currency */
...
}
});
How do I get a custom validation routine to work on multi-page forms?
Thank you.
The alert "currency validate" never displays in the frontend. When you submit that page, the second field is validated that has Number validate, but the first field is now skipped.
First step is to right click the 3rd page and choose "view source", make sure that the code is loaded as intended, if its then you will need to debug it, maybe on a simple 1 page 1 field form first to make sure that it does work.
You may also remove the function from the dom ready event, this may be causing the problem, just define the function in the window namespace.
Regards,
Max
You may also remove the function from the dom ready event, this may be causing the problem, just define the function in the window namespace.
Regards,
Max
Hi,
The input field is showing as:
<input id="volume" class="validate['required', '%currency']" type="text" name="volume" value="eg. $30,000,000" title="" size="30" maxlength="150">
I moved the function out of the domready, but it didn't make any difference.
It is like the validation isn't being called, as the alert is not even triggering.
The input field is showing as:
<input id="volume" class="validate['required', '%currency']" type="text" name="volume" value="eg. $30,000,000" title="" size="30" maxlength="150">
I moved the function out of the domready, but it didn't make any difference.
It is like the validation isn't being called, as the alert is not even triggering.
Did you test it on a new simple form ?
Did you check the page source code to find if the code is loaded in the page ?
Regards,
Max
Did you check the page source code to find if the code is loaded in the page ?
Regards,
Max
Hi,
Yes, the JS code to validate the field is in the source code.
Yes, I tried the code on a single page form and it works as expected. But not, on the multi-page form. I added some alerts in the JS code, but they don't come up like they do on the single page form.
I tried adding the JS code to the first On Load but then the JS code was only in the source code for the first page of the form, subsquent pages didn't have the JS code to do the validation.
Thank you for your help.
Yes, the JS code to validate the field is in the source code.
Yes, I tried the code on a single page form and it works as expected. But not, on the multi-page form. I added some alerts in the JS code, but they don't come up like they do on the single page form.
I tried adding the JS code to the first On Load but then the JS code was only in the source code for the first page of the form, subsquent pages didn't have the JS code to do the validation.
Thank you for your help.
This topic is locked and no more replies can be posted.