The following tutorial was written by Janko Jovanovic of Janko at Warp Speed.
Contact forms are an indispensable part of every website. They are mostly implemented on a separate page and they rarely display creativity, even though there are many ways to improve their visual style. In this tutorial you will see how to create a dynamic, slide-in contact form using jQuery.
Let’s see what we’re trying to achieve with this tutorial. The image below shows the layout of our goal. In the upper right corner of the content is “Contact us” link. When the user clicks on it, the contact form will slide down. When the user submits the form they will get a message that their message has been sent successfully and within two seconds, the entire form will slide up.

Note: You can make this form fully functional by adding validation and some real code that sends the email.
Check out the demo and download full source code here.
Let’s explain the structure first.
We have “contactForm” and “contactLink” divs inside the “contactFormContainer” which is positioned absolutely. ContactForm contains form elements, and contactLink will toggle our contact form on click. Simple enough, right? The CSS code will make this clearer:
And to make this work, we have to add a touch of jQuery.
Let me briefly explain the code above. Clicking on #contactLink div will toggle contact form visibility. Once user submits the form, a message “Your message has been sent successfully!” will appear and the entire form will slide up to its original state.
Check out the demo and download full source code here.
This is just a sample of how you can improve user experience by adding dynamic content to your pages. Besides a contact form, you can create a slide-in login form, search form or anything that you think will improve the user experience.
Is there anything that could be done better? Do you know any other way of doing this? Share some examples!
This is great... seen it done on lots of sites and always wondered how it's done. Thanks!
It is good realization of a good idea. However, it must be improved to fall back if JavaScript is disabled. This can be done by setting the display: none in the css file and setting display:block by JavaScript. Also, the background of the contact form can be improved in at least three ways. Either by setting the background color of the contact form box (not to use the background image) or by making the background image 1px x 1pa and tiling it both horizontally and vertically. And finally, if you use the big background image, it can be preloaded.
The demo could be clearer. A user who just scanned the first few lines of the article should be able to eval the demo. THEREFORE the Contact button should say, "Click me". It took me a while to figure out what to do, including debugging the NoScript plugin settings...
I wonder how long Steven stumbled around in that big form to figure out what to click on?
Sasa, you made good points. Steven, I really don't understand - isn't 'Contact us' link BIG enough? And second: do you really think that 'Click me' is semantically better than 'Contact us' in this case? What would 'click me' mean to anyone?
Brilliantly simple! Thanks for sharing the Jquery. The only comment I might make... while the form is indeed simple it wasn't immediately clear how I could close the form if I decided not to send information. Yes, after some poking around I did determine the Contact Us portion of the form was a toggle switch. Clever though I'm wondering if at least a jquery hover comment of some kind wouldn't be helpful in this instance. Thanks for sharing!
I implemented a similar jquery contact form on my site a few months ago, and it seems to work ok. The only thing I've done differently is that the link to the form is within the normal navigation.
Nice tut! Is it possible to make this come out of the RIGHT side of the page? Still displaying the form the same, of course (would be kinda hard to read and fill out, hah). ?
@mbh - yeah, a small "hide" button would do the work. Nate, you can slide it out of any side, and you can do it by using .animate(...) method.
This is a nice implementation but so obstrusive! There should be a fallback solution but not hiding via css since there would be no contact form at all. Why not linking to a separate contact page if JS is disabled... And yes I had a hard time to find the link in the upper right, a single paragraph of lorem ipsum should be enough.
Thank you, you code was just what I was looking for and using it has explained a few things. I am very new to jquery and javascript Could you possible direct me as to how to add a dark overlay as background .when the form slides in
Hello! It could just be me being dumb, but do you have an extra closing DIV tag in your demo above?
Great stuff. I think I'm in love with the internet.