Examples
A collection of useful examples you can play with
Most asked questions
Basic
- Changing success and error colors
- Clearing field when clicking the icon
- Contact form
- Playing with HTML 5 input types and attributes
- Preventing user to have same value as the placeholder New
- Requiring at least one field
- Setting validator options via HTML 5 attributes
- Supporting multiple date formats
- Terms and conditions agreement validation
- Toggling field
- Using language package
- Using multiple buttons
- Using Google material icons
- Using tooltip to show message
- Validating a form placed inside a Bootstrap modal
- Validating array of inputs
Advanced
- Adding dynamic field
- Adding warning validation state
- Asking fields to be unique
- Building a password strength meter with Dropbox's zxcvbn libary New
- Changing tooltip position
- Complex form
- Conditional validation
- Enabling the submit button
- Enabling validator
- Getting notified while field is being validated Updated
- Hiding messages
- Hiding success class
- Ignoring validation
- Loading and saving data in a modal
- Modifying the value before validating
- Showing custom message returned from server
- Showing icons in custom area
- Showing messages in custom area
- Showing messages in a modal Updated
- Showing only one message each time
- Showing required icon for the mandatory fields
- Showing valid message
- Switching validators on the same field
- Toggling validators in a master page
- Updating validator options
- Using Balloon CSS library to show message New
- Using data returned by validator
- Using hidden field technique New
- Using hint library to show message New
- Using Mailgun API to validate email address
- Validating checkbox list placed in multiple columns
- Validating credit card expiration date
- Validating custom Stripe form
- Validating fields that depend on each other
- Validating Google reCAPTCHA
- Validating international phone numbers
- Validating multiple inputs as one
- Validating percentage values
- Validating start and end date/times
Integrating with server side
These examples shows how to integrate FormValidation with the server side:
Compatibility
In order to make FormValidation work together with other plugin, you should follow two rules below:
-
Don't exclude the field if the plugin changes the field visibility
Some plugins hide your field and create new elements to change how the field looks like. By default, the hidden, invisible fields will not be validated. Therefore, you need to set
excluded: ':disabled'
. See the excluded option for more information.Example: Bootstrap Button
-
Revalidate the field if the plugin changes its value dynamically:
Most plugins trigger an event after changing the field value. By using this kind of event handler, you need to ask FormValidation to revalidate the field.
Look at the revalidateField()
method for more details.
Example: Chosen
These examples show how you can use FormValidation with other Javascript plugins.
- Awesome Bootstrap Checkbox
- Bootbox
- Bootstrap Button
- Bootstrap Combobox
- Bootstrap Datepicker Updated
- Bootstrap Datetime Picker
- Bootstrap Material Design
- Bootstrap Multiselect
- Bootstrap Select
- Bootstrap Slider
- Bootstrap Tabs
- Bootstrap Tags Input Updated
- Bootstrap Touchspin
- Chosen Updated
- CKEditor Updated
- Flat UI
- Fuel UX
- geocomplete
- iCheck
- intl-tel-input
- jQuery UI Datepicker
- Mask
- Pickadate
- Raty Updated
- Select2
- selectize
- Summernote Updated
- TinyMCE
- Typeahead
Wizard
Using FormValidation, you can validate the wizard-like interfaces such as tabs, collapsible panels, accordions.
When using these kind of components, the form fields are split into multiple regions which there is only active, visible one at any time. By default, the invisible fields belonging to inactive regions will be ignored by FormValidation, we need to set excluded: ':disabled'
.
For more information, see the excluded option.
In order to validate particular region, we can use validateContainer(container) method. Then use isValidContainer(container) method to determine the container is valid or not.
Below is the list of examples showing how to use FormValidation with popular wizard plugins:
Supporting other frameworks and form builders
FormValidation supports popular frameworks which are Bootstrap, Foundation, Pure, Semantic UI and UIKit.
It's designed to work with other framework including your own one. This section introduces some examples demonstrating the ways to work with other frameworks and form builders.
Frameworks
- Supporting Spectre framework New
- Supporting Skeleton framework
- Supporting Basscss toolkit Coming soon
- Supporting Titon toolkit Coming soon