By default all major browsers have their own CSS styles for the error messages shown when a form is submitted and some of the fields are empty or with a wrong value.
With this jQuery plugin you can show identical styles for the errors in all major browsers.
In order to have a custom look for the bubbles across all supporting browsers the only option is to suppress the default bubble and implement your own.
required attribute is a must in all the elements that you need to validate.
When you have to validate a group of
<input type="radio" name="group-1"> they must have the same attribute
select element needs to have an empty
option element as the first element so it can get an error if none of the other options are selected
Within HTML5 you can add an extra layer of validation by using the appropiate value for the
type attribute used in the
Using the required attribute for a group of check boxes fails because when you submit the form the error message pops up for the unchecked boxes.
To solve this issue you need to add/remove the
required attribute programmatically. This plugin provides an option that lets you pass the problem.
This is how your error messages will look after using this plugin.
All compiled files can be found under
You will need
It is really simple, just get select your form with jQuery and call the prettyFormError method.
The plugin is initialized with the following default options:
multiCheckbox:enabled: falseclassError: 'prettyFormError'positionMethod: 'after'elementError: 'div'callToAction: 'button'focusErrorOnClick: truefadeOutError:fadeOut: false
Use this option if you need to validate a group of checkboxes.
disabled by default!!
multiCheckbox:enabled: trueselector: '.commonClassForGroup'
Best topping everPineapple:Ham:Olives:
Name for the css class used for the error messages.
JQuery method used for positioning the error,
HTML element that you want to use for wrap the errors.
HTML selector used to submit the form.
false if you want to disable this otpion.
By default the error message will persist on the screen, if you want to fadeout the error enable this option.
fadeOutOpts accepts same options than the default
fadeOut() jQuery method
fadeOutError:fadeOut: truefadeOutOpts: String Number or Object