Skip to content
elclanrs edited this page Aug 24, 2012 · 5 revisions
Filter Description Sample
required 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. 'name': { filters: 'required' }
number Must be a number. 'name': { filters: 'number' }
digits Must be only digits. 'name': { filters: 'digits' }
range Only numbers within a range. Usually combined with number or digits.
'name': {
  filters: 'number range',
  data: { range: [1, 100] }
}
name Must be at least 3 characters long, and must only contain letters. 'name': { filters: 'name' }
username Must be between 4 and 32 characters long and start with a letter. You may use letters, numbers, underscores, and one dot (.) 'name': { filters: 'username' }
pass Must be at least 6 characters long, and contain at least one number, one uppercase and one lowercase letter. 'name': { filters: 'pass' }
strongpass Must be at least 8 characters long and contain at least one uppercase and one lowercase letter and one number or special character. 'name': { filters: 'strongpass' }
email Must be a valid e-mail address. 'name': { filters: 'email' }
phone Must be a valid US phone number. 'name': { filters: 'phone' }
zip Must be a valid US zip code. 'name': { filters: 'zip' }
url Must be a valid URL. 'name': { filters: 'url' }
date 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.
To use the datepicker you need to load jQuery UI and add the class datepicker to your date input. Ideal Forms will apply the custom format that you specify without having to configure the datepicker. It’s seamless.
'name': {
  filters: 'date',
  data: { date: 'dd-mm-yyyy' }
}
dob Must be a valid date of birth in this century, that is 100 years range from the current year.
'name': {
  filters: 'dob',
  data: { dob: 'yyyy/dd/mm' }
}
min Must be at least x characters minimum
Must have at least x checkboxes checked.
'name': {
  filters: 'min',
  data: { min: 10 }
}
max x characters maximum
No more than x checkboxes checked.
'name': {
  filters: 'max',
  data: { max: 10 }
}
exclude 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.
'name': {
  filters: 'exclude',
  data: {
    // Always an array even if just one value
    // Values are case-sensitive
    exclude: ['one', 'two', 'three']
  }
}
equalto The value must match a value of another input.
'name': {
  filters: 'equalto',
  data: {
    // You can use any valid jQuery selector
    equalto: '#myid'
  }
}
extension This filter is designed for file inputs. It supports multifile in HTML5 browsers.
'name': {
  filters: 'extension',
  data: {
    // Always array even if just one
    extension: ['jpg', 'png']
  }
}
Clone this wiki locally