The plugin has the following built-in validation rules, which must be used within data-dj-validator attribute:
The “required” attribute of HTML5 is used to verify that the field is not empty or contains only spaces:
<input type="text" required=”required”/>
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Any text |
text, [min] , [max] |
min : minimum characters allowed. |
Accept any character, validating only length of text. The maximum size can be omitted (*). |
|
Alphabetic text |
atext, [min] , [max] |
min : minimum characters allowed. |
Accepts alphabetic characters in upper and lower case, including spaces, the letter ñ and accented characters (á, é, í, ó, ú, ç, ü), also validating length of text. The maximum size can be omitted (*). |
data-dj-validator="atext,3,12" |
Alphabetical text and digits |
antext, [min] , [max] |
min : minimum characters allowed. |
Accept upper and lower case alphabetic digits and characters, including spaces, the letter ñ and the accented characters (á, é, í, ó, ú, ç, ü), also validating length of text. The maximum size can be omitted (*). |
data-dj-validator="antext,3,12" |
Word (text without spaces) |
word, [min] , [max] |
min : minimum characters allowed. |
Accept any character except spaces, also validating length of text. The maximum size can be omitted (*). |
data-dj-validator="word,4,8" |
Digits only |
dig, [min] , [max] |
min : minimum number of digits allowed. |
Accept a digit text, validating the length of the digit string. The maximum size can be omitted (*). |
data-dj-validator="dig,4,8" |
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Integer numbers |
int, [min] , [max] |
min : minimum value allowed. |
Accept only positive or negative integers (accept the "-" sign ), also validating the value of the whole number. The maximum and/or minimum value of the number can be omitted (*). |
data-dj-validator="int,1,*" |
Real numbers |
num, [min] , [max] |
min : minimum value allowed. |
Accept any type of real number, using the point (.) as decimal separator, accept "-" sign, also validating the number value. The maximum and/or minimum value can be omitted (*). |
data-dj-validator="num,1,*" |
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Email address |
email, [max] |
max : maximum characters allowed. |
Accept valid email addresses of any domain level, also validating maximum number of characters optionally(*). |
data-dj-validator="email,30" |
Web address (url) |
url, [max] |
max : maximum characters allowed. |
Accepts URLs of the HTTP, HTTPS, FTP and FTPS protocols, also validating maximum number of characters optionally(*). |
data-dj-validator="url,50" |
Phone number |
phone |
NONE |
Accepts phone numbers in the following formats: |
data-dj-validator="phone" |
IP adress |
Ip, [type] |
type (optional): ipv4 or ipv6 |
Accepts IP addresses that can be v4 or v6 depending on the specified parameter, if not specified verify both. |
data-dj-validator="ip" |
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Validate files |
file, [min], [max], [min_size], [max_size], [type1 | type2 ..] |
min : minimum number of files to select. |
Validate files based on the javascript file API (if not available, validation is not performed), setting the minimum and maximum of selected files where maximum can be omitted (*), the maximum and minimum size in kb. For each file where both can be omitted (*) and finally validate the file type following the mime types specified as array (at least one is required). |
data-dj-validator="file,2,4,10,100, |
Validate file extensions |
efile, [e1 | e2 | e3 ..] |
e1 | e2 | e3 .. : File extensions allowed |
Validate only the file extension of the selected file within the list of allowed extensions (at least one is required), it can be used more easily and when javascript file API is not available. |
data-dj-validator="efile,jpg|jpeg|png|bmp" |
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Select multiple |
multi, [min], [max] |
min: minimum of selected options. |
Validate the number of options selected from a multiple select, the maximum can be omitted (*). The required attribute is valid to verify that an option with value has been selected. |
data-dj-validator="multi,2,4" |
Radio buttons |
radio |
NONE |
Validate the required selection of a radio button of a group (with the same name), must be placed only a one radio of group (recommended in the last) |
data-dj-validator="radio" |
Checkbox |
check, [group], [min], [max], [label] |
group (optional): Name of the group of checkbox (attribute data-dj-validator-group). |
Without parameters it validates that the checkbox is checked (required). |
data-dj-validator="check" |
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Equal fields |
equal, [id], [label] |
id : id of the input to compare. |
Validate that the value of field is equal to that specified, the [id] must be of field with which you want to compare. The tag is used to label the other field. |
data-dj-validator="equal,a,input a" where "a" is the other field "id" |
Different fields |
nequal, [id], [label] |
id : id of the input to compare. |
Validate that the value of the field is different from the specified, the [id] must be of field with which you want to compare. The tag is used to label the other field. |
data-dj-validator="nequal,a,input a" where "a" is the other field "id" |
Optional fields |
or, [group], [label] |
group : Name of group (fields with the same data-dj-validator-group attribute). |
Validate that at least one field of the group is not empty (required group), the [label] parameter is the label of the group to display message. |
data-dj-validator="or,optionals,optional inputs" where each input group is: data-dj-validator-group = "optionals" |
VALIDATION |
KEY |
PARAMETERS |
DESCRIPTION |
EXAMPLES |
Validate a regular expression |
regexp, [regular_expresion], [flags] |
regular_expresion : regular expression to use. |
Accept field value according to specified regular expression and flags(specified separately), must be in string format (for use with the RegExp object constructor). |
data-dj-validator="regexp,^[aeiou]+$,i" |
Call an own validation function |
call, [function_name] |
function_name : name of the validating function. |
Call a user function to perform the validation, this user function receives the field to be validated ($obj) and must return true or false. |
data-dj-validator="call,isUpperCase" where "isUpperCase" is the user's function |
Check server validation section.