Victor Walch Michnowicz

is a web application developer

AJAX Aware JSON ExpressionEngine Contact Form Module (beta) July 26th, 2010

What’s Wrong With the Default Contact Module?

The default email module for ExpressionEngine 2 is, in my opinion, rather poor. Assume you fill out none of the required fields and hit submit. What happens?

ExpressionEngine error message stating that an email message is required

Totally lame…

Well that is not very helpful. What about the fact that the name field is empty? What about the email field?

Another problem is that the default error (and success) messages are quite ugly. While it is true that you can dress them up and theme them to match your site, it really does not compare at all to what one can accomplish with a bit of AJAX.

The Solution

VWM Contact is a very basic ExpressionEngine contact module. In in current form (version 0.1) it can only deal with contact forms that have name, email, subject, and message fields. And of those fields, only the subject field is optional. Why the lack of super-awesome customization? Well, I designed this module primarily for use on my own site. I am sure that further down the line I will develop this module to be a little more feature-rich.

How it works

VWM Contact is a very simple module. About the only cool thing it does is detect an AJAX response. It does this by looking at the HTTP Request headers. If it sees an X-Requested-With request header with a value of XMLHttpRequest, then it knows we have an AJAX call. With this information, VWM Contact knows whether to output a JSON error/success message, or a generic ExpressionEngine error/success message.

VWM Contact error message in JSON format

JSON rocks my socks off

Limitations

In its current form VWM Contact can not do much other than send an email with a persons email, name, and message. There is no CAPTCHA, multiple recipient,  banned user checking, or naughty word support; it is pretty basic. I am sure that down the road a bit I will get the motivation to further develop the module. Now my focus shall shift to getting my ExpressionEngine comments AJAXed up!

Get Some!

So you wanna try it out?
Download VWM Contact 5.48kb


blog comments powered by Disqus