• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: validation on a conditional multipage form

validation on a conditional multipage form 9 years 11 months ago #27614

  • proxima
  • proxima's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
hello
i have 3 page form.
in the page 1 i have a radio button for user to specify his/her marital status.and the 2nd page is about the spouse information.
i have managed by reading this : www.rsjoomla.com/support/documentation/v...multi-page-form.html to skip the 2nd page when the user is single and show the 2nd page when the user is married.i have set some of the 2nd page components to be required but when the user is single and wants to skip the 2nd page it gives me the validation error(because the page validation is on).how can i do something to avoid this? i mean when the user skip the 2nd page the validation become disabled but when he goes to the 2nd page there will be validations?
thank you
The administrator has disabled public write access.

validation on a conditional multipage form 9 years 11 months ago #27625

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
On your current conditional form, you can implement the conditional fields feature of RSForm!Pro so it suits your needs. (Properties tab > Extras)

The conditional fields will allow you to set the field to be required depending on it's display status.

More information about conditional fields can be found in the following article http://www.rsjoomla.com/support/documentation/view-article/749-conditional-fields.html
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

validation on a conditional multipage form 9 years 1 month ago #30631

  • cstirol
  • cstirol's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi all,

I have a similar problem like proxima but in my case I want to validate the page elements on the page what the costumer just leave. The Pagebreak button's 'Validate When Changing Page?' value is 'yes'. That works well when I don't skip the the next page but when I force to skip it then validation not working. I can type anything in any field, even I can leave reCAPTCHA empty! Form is continuing on the third page without any error.

Please help me!
How can I turn validation on if I skip the next page?

Thx
The administrator has disabled public write access.

validation on a conditional multipage form 9 years 1 month ago #30928

  • wxkeep
  • wxkeep's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
The problem is that the script posted on this site advances the page counter. If your'e on page 2, and want to skip page 3, for example, then the script passes page 3 as the current page (not page 2 where you are) when it calls the changePage function. So it thinks its actually on page 3 and advances to page 4.

This problem likely won't be apparent in instances where your skipped page is to be shown - only in instances when its to be skipped.

To resolve, I added the code from the changePage function that handles the validation:

if (validate)
{
var form = rsfp_getForm(formId);
if (!ajaxValidation(form, page))
return false;
}

just before the new call. So, it looks like:

//the following if clause will address the change page functionality when the "Next" button is used
if(page == 1 && document.getElementById('skip0').checked && typeof validate != 'undefined'){
/* this will check if the user tries to change the page to the conditional page(the second page),if the user
selected to skip this page and if a "Next" button was used*/
if (validate)
{
var form = rsfp_getForm(formId);
if (!ajaxValidation(form, page))
return false;
}
rsfp_changePage(formId, page+1, totalPages, validate);
/* this will trigger the default change page function while incrementing the page parameter one more time so that
the form moves to the third page directly*/
return '';
// this is used so that after the function is triggered the script is stopped
}

This will run the validation script on the current page - before you call the changePage function (and artificially advance the page in the function call with 'page+1')
Last Edit: 9 years 1 month ago by wxkeep.
The administrator has disabled public write access.

validation on a conditional multipage form 6 years 5 months ago #37568

I'm trying to do the same thing. I've got the recpatcha V2 displayed on the first page, but its not validated until the last page. What I've tried is:

- added a php script to the form of:
$formLayout=str_replace('rsfp_changePage','customChangePage',$formLayout);

- added a customChangePage javascript function:
function customChangePage(param1, param2, param3, param4) {
	if (param2 == 1) {
		//first page
		var $passed = true;
		if (!checkEmail(param1)) $passed = false;
		if (!checkPassword(param1)) $passed = false;
		if (!validateCaptcha(param1, param2)) $passed = false;
 
		if (!$passed) return false;
	}
	document.body.scrollTop = document.documentElement.scrollTop = 0;
	return rsfp_changePage(param1, param2, param3, param4);
}
- added functions called from above (disregard checkPassword, and checkEmail they work fine!). How do I write the validateCaptcha function? I tried code from the above comment but didn't get anywhere?
function validateCaptcha(theForm, thePage) {
   //return false if captcha validated, else false
   ???
}
This is for a long scholarship application for potentially disabled students, so I would like to get the captcha validated on the first page. I could put it last - but this may be frustrating for some disabled kids if they lose all the info they put in previously.
Last Edit: 6 years 5 months ago by richedgar. Reason: fix up code display
The administrator has disabled public write access.

validation on a conditional multipage form 6 years 4 months ago #37645

  • fresco
  • fresco's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi richedgar, did you solve in some way and could you share with us how did you do?
The administrator has disabled public write access.

validation on a conditional multipage form 6 years 3 months ago #37760

I never got it working. I think I eventually realized that due to the way the recaptcha works that it would be impossible to write. I'm now not using a captcha on this form at all. Fortunately there enough other fields that have validation that spam has not been a problem. One thing you could try is writing your own custom captcha. For example you could have a simple math problem (Enter the result of 1 + 1) or even just ask for a static value or a question of some sort. Then using a custom page change validate the result of the entry.

As an example, assuming the id of the entry box for the math problem is "customCaptcha":

function checkCustomCaptcha(theForm) {
if (document.getElementById('customCaptcha').value != 2
{
document.getElementById('component758').className = 'formError';
return false;
}
else {
document.getElementById('component758').className = 'formNoError';
return true;
}
}

The component758 would need to be updated to reflect the auto generated id for the area where the component error message would get displayed. (I use firebug to figure this out). The class of formError make it visible, turns it red, and displays whatever message you specify in your 'Validation Message" of the form field. (there may be some way to force the id of this part of your DOM in the form layout)

This would get called in the customPageChange script I put above. (warning I haven't tested the above code although I have used this method before to create a custom captcha)
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!