Problem is that when I have done that and do a preview it hasn't added the form on the page.
When I manually add html for it it simply sends all the form data through GET and nothing happens.
You don't need to use JQuery to process the form, just paste the {% component 'contactForm' %} into the page, and that's it.
If you want to customise the layout, look in [PLUGINS > LAMINSANNEH > FLEXICONTACT > COMPONENTS > CONTACTFORM > default.htm], no need for JQuery at all.
Yeah I know but I want to add some extra visual functionality. For example, if error occurs I would show an error message somewhere instead of current alert.
Form for some reason is sent as simple GET request without JS. Any help here would be appreciated.
P.S. Does the component need to be attached to the page if I'm not using {% component "contactForm" %} in it?
P.P.S. Editing posts is broken as well as html tags should be escaped.. :)
Looking at that latest JS, you're targeting the wrong events. I think, I'm not a great JS programmer but I've always used something like below to do custom form validation.
$(function() {
$("#submitHireUs").on('click', function(event) {
event.preventDefault();
// Your code here
});
});
I can't help with the rest sorry, as I haven't played with the front end forms yet, but hopefully this will help you.
Just sorted it out. Thanks everyone who helped as it got me to the result I wanted. Here is a simplified version that makes and handles all requests for the contact form in javascript.
Just one question, you said you wanted to show custom error messages rather than alerts, so how would you integrate that functionality in the method above? I only ask because the method you've written above is pretty much what the Ajax framework does already, and you can return custom alerts from the PHP "onMailSent" function, so just wondering how you'd show custom visual changes / errors?
Because you alert the $el.responseText, is there a way of customising that for different types of errors with different messages?
I stripped down this example just to show that this works. I have my own custom styles and frontend methods to show notifications/warnings/errors which simply replaces the alert method but still uses the responseText to get the error message.
Basically what I have for error message is this: Ex.System.showError($el.responseText) which shows error message with custom styling above the form.
Hope it helps ;)
I don't think there is private messaging system here but you can find me on Facebook if you want by searching "Martin Tale" and we can continue discussion. Because I think this thread has been resolved now. :)