Skip to content


Subversion checkout URL

You can clone with
Download ZIP
The ultimate framework for building and validating responsive HTML5 forms.
Branch: gh-pages
Pull request Compare This branch is 894 commits ahead, 27 commits behind elclanrs:gh-pages.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Ideal Forms

Ideal Forms is the ultimate framework for building and validating responsive HTML5 forms.

  • DEMO
  • Support: IE8+, Webkit, Firefox, Opera, iOS 5+.
  • jQuery 1.7+, jQuery UI 1.8+
  • License: GPL or MIT


  • Fully responsive (AKA adaptive, adapts to the container, no css media queries needed).
  • Keyboard support.
  • Every input type can be customized including select, radio, checkbox and file.
  • Custom datepicker using jQuery UI (with fallback)
  • "On the spot" validation.
  • Localization
  • HTML5 placeholder for every browser.



  • New tabs(steps) with new public methods switchTab, nextTab, prevTab, firstTab and lastTab.
  • New custom datepicker (requires jQuery UI)
  • New method removeFields and new option addBefore in addition to addAfter for the addFields method.
  • Added separators and headings with descriptions. Check out demo.


"Help translating Ideal Forms into other languages."
"I need feedback for mobile devices. Please report any bugs you might find in iOS or Android."

How to use it:

Load the latest jQuery library, the js/min/jquery.idealforms.min.js plugin and the css/jquery.idealforms.css stylesheet into your project. Load the latest jQuery UI if you want support for datepicker.

Replace your document's opening <html> tag with the following conditional comments. This will load the appropiate fixes for all supported IE versions:

<!--[if IE 8]> <html class="ie8" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="ie9" lang="en"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->

Also, for IE8 support you'll need an HTML5 shim unless you're using Modernizr which already has a shim.

To localize Ideal Forms in your language, load the corresponding file from js/i18n after loading the plugin.



For Ideal Forms to work its magic create your markup using the following template as a reference, nothing fancy, just the usual form tags wrapped in a <div>. Drop the form into a container of any size and Ideal Forms will do the rest.

If you're working with dynamic fields check documentation on addFields.

<form id="my-form">

  <!-- TAB -->
  <section name="First tab">

    <!-- Heading -->
      <h1>My Heading</h1>
      <p>Description here</p>

    <!-- Text -->
    <div><label>Username:</label><input type="text" name="username"/></div>
    <div><label>Date:</label><input type="text" name="date" placeholder="mm/dd/yy"/></div>
    <div><label>Comments:</label><textarea name="comments"></textarea></div>

    <!-- File -->
    <div><label>File Upload:</label><input type="file" multiple name="file"/></div>

    <!-- Select -->
      <select name="colors">
          <option value="Choose a color">Choose a color</option>
          <option value="Red">Red</option>
          <option value="Blue">Blue</option>
          <option value="Green">Green</option>

  <section> <!-- END TAB -->

  <!-- TAB -->
  <section name="Second tab">

      <h1>My Heading</h1>
      <p>Description here</p>

    <!-- Checkbox -->
      <label><input type="checkbox" name="langs[]" value="English"/>English</label>
      <label><input type="checkbox" name="langs[]" value="Chinese"/>Chinese</label>
      <label><input type="checkbox" name="langs[]" value="Spanish"/>Spanish</label>

    <!-- Radio -->
      <label><input type="radio" name="options" value="One"/>One</label>
      <label><input type="radio" name="options" value="Two"/>Two</label>
      <label><input type="radio" name="options" value="Three"/>Three</label>

  <section> <!-- END TAB -->

  <!-- Separator -->

  <!-- Buttons -->
  <div><input type="sumbit" value="Submit"/></div>


The name attribute will be used in the plugin's options to add filters to each input. This provides a lot of flexibility and the possibility to create custom errors, and tweak the filter's values.

Alternatively, for very simple forms, you can do it "the easy way" and just add the filters as classes.

<form id="my-form">
  <div><label>Username:</label><input type="text" name="username" class="required username"/></div>
  <div><label>Password:</label><input type="text" name="password" class="required password"/></div>
  <div><label>E-Mail:</label><input type="text" name="email" class="required email"/></div>

Invoke the plugin

Call Ideal Forms on each form separately. Assign each form to a variable to have access to the public methods.

var $myform = $('#my-form').idealforms({ options });



Add all the inputs you want to validate here. Use the name attribute of the input as key. To be consistent always put the key in quotes. Array group names can be used too, ie. name[].

Each input can be customized with filters, data, errors and flags.

  • filters: A space separated string of filters.
  • data: Filters that take values can be specified in here. Check documentation on Built-in filters for more info.
  • errors: Use the filter name as the key value and add your custom error. You can use inline HTML tags within the error string.
  • flags: Flags are simply functions that run when an input tries to validate. See documentation on Built-in flags and customFlags.
inputs: {
  // The name attribute of the input in quotes
  'myinput': {
    filters: 'required min',
    data: {
      min: 10
    errors: {
      min: 'At least 10 characters'
    flags: 'noclass noinvalidicon'


Adding custom filters is very easy and straightforward.

customFilters: {
  custom: {
    regex: /regularexpression/,
    error: 'My custom error'
  another: {
     * @param {object} input Contains two objects,
     * the user options of the input as [input.userOptions]
     * and the jQuery element as [input.input]
     * @param {string} value The value of the input
     * @return {bool} Truthy or falsy values too
    regex: function(input, value) {
      // Declare error within `regex`
      // to have access to `value` and `input`
      this.error = 'My custom ' + value;


Disables custom inputs and uses system default. (select, radio, checkbox, button, file)

customInputs: false


Add custom flags:

customFlags: {
   * @param input jQuery input object
   * @param event The event that was triggered on the input (focus, blur, change, keyup)
  custom: function(input, event){
    if (event === 'keyup') console.log(input.val())


List the flags that you want to apply to all inputs.

globalFlags: 'noerror noicons'


onSuccess: function(e){
  // Form validates


onFail: function(){
  // Form does NOT validate


By default, Ideal Forms will make the form "adaptive". It will adapt to the container allowing it to work with any responsive grid system. You can change this behavior by assigning a number value to the responsiveAt option.

// Make responsive only at a certain window size.
// Default is `"auto"` to adapt to the container
// Set to `false` to disable responsiveness
// To always show the responsive layout use a large number ie `3000`
responsiveAt: 480

Built-in filters

You may use any of these filters in any order.


The field is required. This filter ONLY works with text inputs (text, password, textarea). For select use exclude to exclude the default option. For radio and checkbox use min: 1 which will require at least one option to be checked.


Must be a number.


Only digits.


Must be at least 3 characters long, and must only contain letters.


Must be between 4 and 32 characters long and start with a letter. You may use letters, numbers, underscores, and one dot (.)


Must be at least 6 characters long, and contain at least one number, one uppercase and one lowercase letter.


Must be at least 8 characters long and contain at least one uppercase and one lowercase letter and one number or special character.


Must be a valid e-mail address.


Must be a valid US phone number.


Must be a valid US zip code.


Must be a valid URL.


Must be a valid date. This filter effectively validates a date, so stuff like 02-31-2012 or 30/80/2000 would be invalid. You can use any format with 4 digit year and any delimiter character. The default format is mm/dd/yyyy.

If you're loading jQuery UI, Ideal Forms will detect it and use the datepicker plugin to choose dates. It will also apply the custom format that you specify without having to configure the datepicker. It's seamless.

'myinput': {
  filters: 'date',
  data: {
    date: 'dd-mm-yyyy' // or `yyyy~dd~mm` or `mm*yyyy*dd`...


  • Must be at least x characters minimum.
  • Must have at least x checkboxes checked.
'myinput': {
  filters: 'min',
  data: {
    min: 10


  • x characters maximum.
  • No more than x checkboxes checked.
'myinput': {
  filters: 'max',
  data: {
    max: 10


  • Prevent validation if the value matches any value in the given array.
  • Use this filter to exclude the default (usually first) option of a select input.
  • Useful to validate usernames from a database; just pull a list of the usernames that are already taken and pass in an array. Store the array in an external variable and as the array is updated Ideal Forms will respond accordingly.
'myinput': {
  filters: 'exclude',
  data: {
    // Always an array even if just one value
    // Values are case-sensitive
    exclude: ['one', 'two', 'three']


The value must match a value of another input.

'myinput': {
  filters: 'equalto',
  data: {
    // You can use any valid jQuery selector
    equalto: '#myid'


This filter is designed for file inputs. It supports multifile in HTML5 browsers.

'myinput': {
  filters: 'extension',
  data: {
    extension: ['jpg', 'png'] // Always array even if just one

Built-in flags

  • noerror: hide the error from the input
  • noicons: hide the icons
  • novalidicon
  • noinvalidicon
  • noclass: no valid/invalid class
  • novalidclass
  • noinvalidclass



Check if the form is valid.

chainable: no

if ($myform.isValid()) {
  // do something...


Add fields to the form dynamically. It takes an array of objects. Ideal Forms auto-generates the markup for inputs fields based on the type specified.

chainable: yes

name (required)

The value used as name attribute.

title (required)

The label text.


Insert the new field before an existing field. Takes a string. Ideal Forms will look for name first and then id.


Insert the new field after an existing field.

type (required)

text, password, email, number ,search, url ,tel, file, select, radio and checkbox.


Array of items for inputs such as select, radio and checkbox.


The placeholder for text inputs. Use exclude for select menus.

filters, data, errors, flags

For more info check documentation on input's options.

var newFields = [
    name: 'animals[]',
    title: 'Animals',
    addAfter: 'email',
    type: 'radio',
    list: ['Dog', 'Elephant', 'Crocodile', 'Spider']
    name: 'zip',
    title: 'Zip Code',
    filters: 'required zip',
    type: 'text'
    name: 'instruments',
    title: 'Instruments',
    addBefore: 'langs[]',
    filters: 'exclude',
    data: { exclude: ['Select an instrument'] },
    errors: { exclude: 'Please select an instrument' },
    type: 'select',
    list: [
      'Select an instrument',


Remove fields from the form dynamically. It takes an array of names or id's. Ideal Forms will look for the name attribute first and then id.

chainable: yes

var fields = [


Check if a particular field is valid. The function takes a string. Ideal Forms will look for the name attribute first and then for the id. You can use array group names for groups of checkboxes.

chainable: no

if ($myform.isValidField('username')) { // name="username" OR #username
  // do something...
if ($myform.isValidField('colors[]')) { // name="colors[]"
  // do something...


Get all invalid fields. Returns a jQuery object. You can also filter by tab name to get all invalid fields within a tab.

chainable: yes (but it doesn't return the form, just the invalid fields)

var numInvalid = $myform.getInvalid().length // How many invalid fields
var numInvalidTab = $myform.getInvalid('My Section').length


Focus the very first field.

chainable: yes



Focus the first invalid field.

chainable: yes



Change tab by name.

chainable: yes

$myform.switchTab('My Section')


Go to next tab.

chainable: yes



Go to previous tab.

chainable: yes



Go to first tab.

chainable: yes



Go to last tab.

chainable: yes



Load the form as if it was never focused. This removes valid and invalid classes until first focus.

chainable: yes

$myform.reset().fresh() // Usually combined with `reset()`


Reset all fields to zero including checkboxes, radios, and selects.

chainable: yes



With the markup provided above you'd call the plugin like this:


  inputs: {
    'username': {
      filters: 'required username exclude',
      data: {
        exclude: ['user', 'username', 'admin']
    'date': {
      filters: 'date'
    'comments': {
      filters: 'min max',
      data: {
        min: 50
        max: 200
    'colors': {
      filters: 'exclude',
      data: {
        exclude: ['Choose a color']
      errors: {
        exclude: 'Choose a color from the list.'
    'langs[]': {
      filters: 'min',
      data: {
        min: 2
      errors: {
        min: 'Check at least <strong>2</strong> languages.'
    'options': {
      filters: 'min'
      data: {
        min: 1
      errors: {
        min: 'Check only <strong>1</strong> option.'


Ideal Forms relays on a carefully crafted LESS stylesheet. Everything is customizable, from the simplest text input, to the select menus, radios, and checkboxes.

Custom UI elements:

Here's a list of all the Ideal Forms UI elements that can be customized:

  • Tabs
  • Labels
  • Headings
  • Separators
  • Icons
  • Errors
  • Text inputs
  • Buttons
  • Select dropdowns
  • Radios
  • Checkboxes
  • Datepicker


User config:

All user options are located in less/themes/theme/theme.less. You can safely edit all values from the "user config". The "extra" options must be edited wisely since most of the variables here are relative to other variables defined elsewhere.

The names of the user config variables are pretty self-explanatory. If you screw up you can always go back. When you finish editing the user config don't forget to load your theme in less/jquery.idealforms.less and compile into css.


The overall font size. Usually adjusting this option should be enough in most cases. Keep in mind that the bigger the font, the bigger the icons need to be. Ideal Forms will try to align everything as close as possible, but it's recommended that the icons are aprox. the same size as the font-size.


Ideal Forms uses a smaller font-size for button, select, radio, checkbox and file. This makes UI elements stand out more and feel more integrated. Change to 100% to use the default font-size.


Adjust this option if the form doesn't quite fit your container. It's recommended to use this format @font-size * number. All inputs will have the width set here but you can change the width of any particular input by targeting its id. This won't affect the responsive layout.

#comments { width: 200px; }


Align labels to either left or right.


Most of the time auto will work just fine but if you have really long label names then it's a good idea to tweak this value.


Width of every border property. Usually there's no need to change the default value of 1px unless you want a "thick" border look, suitable for some occasions. box-shadow properties depend on this option.


Radius for round corners.


true or false to enable or disable css3 animations (transitions).


true or false to enable or disable css3 box-shadow and gradients.

Enjoy :)

Something went wrong with that request. Please try again.