Predefined Rules

Use it or define your own.

XRule already has several rules. You can use it without any single line of javascript code. If you need some other functions then you can define your own rule and add it to XRule. Of course you can override message and function. It means you can redefine predefined rules below. If you are interested in it. Click 'Localize Message' or 'Add User Defined Rules' on menus.

Look at the first columns. Rule consits of 2 parts. Those are name and arguments. You can sepecify arguments in brackets. Once XRule parse data-xr attribute, arguments became an javascript string array. Finally when XRule notify violation message, first argument will match {1}, second argument will match {2} and so on.

Name(args) Message
req() required.
num() Only numbers are allowed.
email() Invalid email address format.
minlen(#) Minimum {1} letters.
maxlen(#) Maximum {1} letters.
len(#,#) {1}~{2} letters.
gt(#) Input greater than {1}.
ge(#) Input greater than or equal to {1}.
lt(#) Input less than {1}.
le(#) Input less than or equal to {1}.
between(#,#) Input between {1} and {2}.
fsize(#,#) Maximum size is total {1}KB and each file {2}KB.
fcnt(#) Too many files. Maximum file count: {1}.
fallow(...) Only filename extensions '{}' are allowed.