Topic: custom jquery/ajax form in a sidebar template page
I made a custom form in a sidebar template page – a plugin is not an option. I got the validation working but the processing runs foul. Next I will explain in more detail what I did.
Let me start off by saying: I am noob (and that’s probably stretching it). My problem – in short – is that a contact form validated with the jquery validation plugin, and submitted through ajax does not end up in my mailbox. And yes, I have a form processor php scrip attached but something goes wrong. But I don’t know what.
My own guess
Before I will show you the custom scripts I want to address what I think is going foul. I made a valid html form. I used the jquery validation plugin to use the validate function on the various fields. And I added some custom jquery to tell the validation plugin exactly what fields are required. On top of that I added ajax, via the jquery form plugin, so that the form doesn’t reload upon submittal.
Now the validation works – see for yourself here. And as soon as all fields are filled out correctly, and I press submit ajax kicks in because I see the button value change as intended. After a short load – sending sequence – the button changes to ‘message send’. But I receive no email. And I have checked my spam folder: it’s empty. In previous tests – with a different script – I did receive emails with the contact form values (but there were other issues).
I am using this contact form in a WordPress template. Perhaps it is the php processor? But I can’t see what’s wrong with that file.
Also in Firebug, under ‘console’ I see a GET string with the form values after submittal.
My question is. Can someone take a look at the form (because I think the post action might be wrong, the form processor is located in the template file), the custom jquery script and the php script? Plus after the form is successfully submitted, via ajax, I would like the form to reset, to clear all fields; how would I do that?
Btw I read somewhere I can use a WordPress function to add the admin e-mailaddress in the php form processor – where you would normally put down the receivers emailaddress. Is this true? And how would I do this?
Any help is seriously appreciated. Thank you for your time.
You can check the script and code over at Pastebin:
Sidebar template page containing the htlm form
Custom jquery form validation script
Php form processor