See the dojox/validate/web reference documentation for more information.
validates user input of an HTML form based on input profile
returns an object that contains several methods summarizing the results of the validation
Parameter | Type | Description |
---|---|---|
form | HTMLFormElement | form to be validated |
profile | Object | specifies how the form fields are to be validated {trim:Array, uppercase:Array, lowercase:Array, ucfirst:Array, digit:Array, required:Array, dependencies:Object, constraints:Object, confirm:Object} |
Generate the DV code (checksum part) for a Cnpj number
Parameter | Type | Description |
---|---|---|
value | String | The CGC number in ##.###.###/#### or ############ format |
Generate the DV code (checksum part) for a CPF number
Parameter | Type | Description |
---|---|---|
value | String | The CPF number in ######### format |
Evaluates dojo.validate.check() constraints that are specified as array arguments
The arrays are expected to be in the format of:
constraints:{ fieldName: [functionToCall, param1, param2, etc.], fieldName: [[functionToCallFirst, param1],[functionToCallSecond,param2]] }
This function evaluates a single array function in the format of: [functionName, argument1, argument2, etc]
The function will be parsed out and evaluated against the incoming parameters.
Parameter | Type | Description |
---|---|---|
profile | undefined | The dojo.validate.check() profile that this evaluation is against. |
constraint | Array | The single [] array of function and arguments for the function. |
fieldName | undefined | The form dom name of the field being validated. |
elem | undefined | The form element field. |
Check if value is an email address list. If an empty list is returned, the value didn't pass the test or it was empty.
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional An object (same as dojo.validate.isEmailAddressList) |
Checks if a string could be a valid email address
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional
|
Checks if a string could be a valid email address list.
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional
|
Validates whether a string denoting a number is between a max and min.
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional {max:Number, min:Number, decimal:String}
|
Validates an IP address
Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. Supports 2 formats for Ipv6.
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional All flags are boolean with default = true.
|
Validates any sort of number based format
Validates any sort of number based format. Use it for phone numbers, social security numbers, zip-codes, etc. The value can be validated against one format or one of multiple formats.
Format Definition
# Stands for a digit, 0-9. ? Stands for an optional digit, 0-9 or nothing.
All other characters must appear literally in the expression.
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional
|
"(###) ###-####" -> (510) 542-9742 "(###) ###-#### x#???" -> (510) 542-9742 x153 "###-##-####" -> 506-82-1089 i.e. social security number "#####-####" -> 98225-1649 i.e. zip code
require(["dojox/validate/_base"], function(validate){ // returns true: validate.isNumberFormat("123-45", { format:"###-##" }); });
Check Multiple formats:
require(["dojox/validate/_base"], function(validate){ validate.isNumberFormat("123-45", { format:["### ##","###-##","## ###"] });
Validates 10 US digit phone number for several common formats
Parameter | Type | Description |
---|---|---|
value | String | The telephone number string |
Validates social security number
Parameter | Type | Description |
---|---|---|
value | String |
Validates US state and territory abbreviations.
Parameter | Type | Description |
---|---|---|
value | String | A two character string |
flags | Object |
Optional
|
Checks if a string has non whitespace characters. Parameters allow you to constrain the length.
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional {length: Number, minlength: Number, maxlength: Number}
|
Checks if a string could be a valid URL
Parameter | Type | Description |
---|---|---|
value | String | |
flags | Object |
Optional
|
Validates a CNPJ/CGC number
Parameter | Type | Description |
---|---|---|
value | String | The CNPJ/CGC number in ##.###.###/####-##, ########/####-##, ######-## or ############## format |
Validates a CPF number
Parameter | Type | Description |
---|---|---|
value | String | The CPF number in #########-## or ###########, format |
Validate a credit card number by type with Luhn checking.
Checks if a credit card type matches the # scheme in a passed value, and if the Luhn checksum is accurate (unless its an Enroute card, in which case the checkSum is skipped), returning a Boolean to check against.
Parameter | Type | Description |
---|---|---|
value | String | Int | A Value (credit card number) to validate |
ccType | String | A credit-card abbreviation. |
if(dojox.validate.isValidCreditCard("12345", "mc")){ console.log('inconceivable'); }
Checks if value matches the pattern for that card or any card types if none is specified
Parameter | Type | Description |
---|---|---|
value | String | Int | CC #, white spaces and dashes are ignored |
ccType | String |
Optional One of the abbreviation values in |
Validate the security code (CCV) for a passed credit-card type.
Parameter | Type | Description |
---|---|---|
value | String | Int | |
ccType | String |
Validate ISBN-10 or ISBN-13 based on the length of value
Parameter | Type | Description |
---|---|---|
value | String | An ISBN to validate |
Validate a String value against the Luhn algorithm.
Validate a String value against the Luhn algorithm to verify its integrity.
Parameter | Type | Description |
---|---|---|
value | String |