JordanLev's Custom Contact Form - Validation
I'm using the custom contact form, which is working great, apart from validation. I can see the validation within the php (required etc) but I have included an automatic page change once the form has been submitted.
Here is the source code below:
<input type="submit" id="submit" value="Submit" class="btn btn-lg btn-primary" onclick="window.location.href='/thanks-for-requesting-a-callback/'" role="button" />
Is there a way I can validate the code before it gets sent as the contact form is being sent regardless at the moment.
The "onclick" code you have on that button is bypassing the actual form submission. (You're basically telling the browser "don't actually submit this form, but instead go to some other page").
$redirect = Loader::helper('navigation')->getCollectionURL(Page::getCurrentPage());
Change that line to this instead:
$redirect = Loader::helper('navigation')->getCollectionURL(Page::getByPath('/thanks-for-requesting-a-callback'));
but what happens when you have more than one form? How do you specify a certain thanks page to a particular contact form?
If that's something beyond your area of expertise, and you have a budget for this project then my company could take on the task for you -- just email [email protected] and someone will be in touch with more questions and/or a quote for you.