Adding animation to an HTML form not only makes it looks slick but can help communicate to users when they've made a mistake. This tutorial will teach you how to create a Bootstrap Form and add animations to it.
- We'll add a shake when the form is submitted with errors.
- We'll fade out the form after it is successfully submitted.
- Then, we'll fade in a "thank you" message.
Customize Demo Online
To create our animated form, we'll need the following:
- jQuery 1.9+ (cdn)
- jQuery UI Shake Effect
You either need to use jQuery UI or simply add this snippet which has extracted the shake effect from jQuery UI for you.
- Bootstrap 3 (cdn)
If you aren't using Bootstrap on your site, you can use this isolated version of bootstrap. You don't have to use Bootstrap, but it will be easier to follow this tutorial if you do.
The header of your webpage should look something like this:
<!-- jQuery -->
This tutorial will teach you how to customize the the focus color and drop shadow in a Bootstrap form field. By default, a Bootstrap form field is blue with a drop shadow and looks like this when it is in focus:
Overall, this is a pretty clean modern look. However, it can look out of place if your site uses a different color palette or aesthetic vibe. For example, suppose you're using a green submit button via
Suddenly, the blue looks out of place. Moreover, the drop shadow on the input is not really consistent with the flat button. It looks much better after we remove the drop shadow and change the
<input> focus color to match the green in the submit button.
This can be done using our free Bootstrap form builder or by coding the CSS by hand. I'll demonstrate both approaches.
Fast and Easy Approach: Bootstrap Form Builder
You can create a form with custom focus color and shadow fields with our form builder by following these simple steps:
- Go to https://formden.com/form-builder/. You'll start with a default contact form. Customize the fields as you like.
- Click on the Settings tab ...