Difference between revisions of "NATS4 Form Validation"
(Created page with "{{NATS4 Manual | show_sites_admin_section = true }} NATS forms have built in validation checks on form fields. These require that the form be submitted for NATS to valid...") |
|||
Line 16: | Line 16: | ||
== username_check_detailed == | == username_check_detailed == | ||
− | You can set detailed limitations on usernames by passing arguments to the special check function. For example: | + | You can set detailed limitations on usernames by passing arguments to the special check function. For example:<br> |
''<nowiki>[username:1:6:16:::username_check_detailed;1|4|9|||]</nowiki>''<br> | ''<nowiki>[username:1:6:16:::username_check_detailed;1|4|9|||]</nowiki>''<br> | ||
Line 26: | Line 26: | ||
#(Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check) | #(Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check) | ||
#(Flag 1 or 0) - Defines whether or not all characters MUST be lower case (This overrides the numeric upper case check) | #(Flag 1 or 0) - Defines whether or not all characters MUST be lower case (This overrides the numeric upper case check) | ||
− | + | <br> | |
− | In the example | + | In the example above, the limitations set for the Username are:<br> |
− | |||
− | |||
− | |||
# The first character must be a letter | # The first character must be a letter | ||
# There must be at least 4 upper case letters | # There must be at least 4 upper case letters | ||
Line 37: | Line 34: | ||
== password_check_detailed == | == password_check_detailed == | ||
− | You can set detailed limitations on passwords by passing arguments to the special check function. For example: | + | You can set detailed limitations on passwords by passing arguments to the special check function. For example:<br> |
''<nowiki>[password:1:6:16:::password_check_detailed;1|||5|3|1|]</nowiki>'' | ''<nowiki>[password:1:6:16:::password_check_detailed;1|||5|3|1|]</nowiki>'' | ||
Line 48: | Line 45: | ||
#(Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check). | #(Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check). | ||
#(Flag 1 or 0) - Defines whether or not all characters MUST be lower case (This overrides the numeric upper case check). | #(Flag 1 or 0) - Defines whether or not all characters MUST be lower case (This overrides the numeric upper case check). | ||
− | + | <br> | |
− | + | In the example above, the limitations set for the Password are: | |
− | In the example | ||
# The first character must be a letter | # The first character must be a letter | ||
# There must be at least 5 Numeric Characters | # There must be at least 5 Numeric Characters |
Revision as of 20:06, 2 December 2016
NATS forms have built in validation checks on form fields. These require that the form be submitted for NATS to validate them. For example, on the join form, you will see that the input names look like: signup[username:1:6:16:::username_check]
"signup" is the array that contains all submitted inputs. The format for each is:
- name of the input - In this example: username
- required flag - If set to 1, this input must be submitted
- minimum - the minimum length of the input
- maximum - the maximum length of the input
- compare - you can specify another input name here to compare the values. If set, the two inputs must match
- session compare - you can specify a session variable name here to compare to the input value. If set, the input must match the session variable's value
- special check - you can specify a check function for NATS to run on the input. The following are the avaialble check functions:
username_check_detailed
You can set detailed limitations on usernames by passing arguments to the special check function. For example:
[username:1:6:16:::username_check_detailed;1|4|9|||]
The details after the "username_check_detailed;" separated by a pipe "|" define the arguments:
- (Flag 1 or 0) - Defines whether or not the first character MUST be a letter
- (Numeric) - Defines the minimum number of upper case characters there needs to be
- (Numeric) - Defines the minimum number of lower case characters there needs to be
- (Numeric) - Defines the minimum number of Numbers (0-9) there needs to be
- (Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check)
- (Flag 1 or 0) - Defines whether or not all characters MUST be lower case (This overrides the numeric upper case check)
In the example above, the limitations set for the Username are:
- The first character must be a letter
- There must be at least 4 upper case letters
- There must be at least 9 lower case
password_check_detailed
You can set detailed limitations on passwords by passing arguments to the special check function. For example:
[password:1:6:16:::password_check_detailed;1|||5|3|1|]
The details after the "password_check_detailed;" separated by a pipe "|" define the arguments:
- (Flag 1 or 0) - Defines whether or not the first character MUST be a letter.
- (Numeric) - Defines the minimum number of upper case characters there needs to be.
- (Numeric) - Defines the minimum number of lower case characters there needs to be.
- (Numeric) - Defines the minimum number of Numbers (0-9) there needs to be.
- (Numeric) - Defines the minimum number of Special Characters there needs to be (Anything that is not a letter or a number).
- (Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check).
- (Flag 1 or 0) - Defines whether or not all characters MUST be lower case (This overrides the numeric upper case check).
In the example above, the limitations set for the Password are:
- The first character must be a letter
- There must be at least 5 Numeric Characters
- There must be at least 3 Special Characters
- Any Alphabetic characters must be uppercase
strong_email_check
You can add the check "strong_email_check" to have the domain of the email (everything after the @) checked for MX records using the PHP function getmxrr: http://php.net/manual/en/function.getmxrr.php
This check does not take additional arguments.
If you are using this check, you will want to ensure the "dns-search" directive on your server is turned off. This can create issues with the function