NATS4 Form Validation

From TMM Wiki
Jump to navigationJump to search
NATS 4
Members Admin
The Members Admin
View Member Details
Add Member
MySQL Auth
Mod Authn DB
Multisite Access
Member Logging
Member Password Retrieval
OpenID Connect
Mod Auth OpenIDC
ID Numbers
Sites Admin
The Sites Admin
Sites
Site Setup
Site Templates
Tour Setup
Join Options
No Cost Registration
Special Pricing Options
Join Option Rules
Post URL Usage
Post URLs in NATS4
Approval/Upgrade/Denial Variables
Approval/Upgrade/Denial Template Variables
Mobile Tours
Token Sites
ID Numbers
Site Partner
Site User Management
Example Postbacks for Site User Management
Configure Redirects
Split A-B Testing
Username Checking
Form Validation
Post-Biller Templates
Send Information To Special Biller
Join Option Box vs Button
Qualified Join Page Hits
Allowed languages
Customize Join Form
Package Plus
Token Plus
Signup Plus
Type-In Traffic
Coupon Codes
Setting Rules
Site Groups
Options Simulator
ATVOD Verification Process
Skins and Templates Admin
The Skins and Templates Admin
Skins
Templates
Site Templates
Language Skins
Language Files
custom_errors.php
Join Page Variables
Skipping NATS Join Form
Post URL Variables
Member Usernames & Passwords
Form Validation
Username Recommendations
Password Retrieval
Post-Biller Templates
Geo-Target Join Options
Random Usernames and Passwords
Smarty
Smarty print array
Smarty Plugins
Available Smarty Functions
Affiliate Support Template
Adding a Verification Image
Custom Program and Campaign Selection Pages
Output An Affiliate's Last Paid Date
Affiliate Signup Email
Affiliate Join Page Linkcodes
Approval/Upgrade/Denial Variables
Approval/Upgrade/Denial Template Variables
CSS Theme Builder

Form Inputs

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 have the following structure:
signup[username:1:6:16:::username_check]

"signup" is the array that contains all submitted inputs. The format for each is:

  1. name of the input - In this example: username
  2. required flag - If set to 1, this input must be submitted
  3. minimum - the minimum length of the input
  4. maximum - the maximum length of the input
  5. compare - you can specify another input name here to compare the values. If set, the two input values must match
  6. session compare - you can specify a session variable name here to compare to the input value. If set, the input value must match the session variable's value
  7. special check - you can specify a check function, or multiple check functions (separated by a comma) for NATS to run on the input.

Check Functions

The avaialble check functions are detailed below. Some allow you to pass additional arguments to customize the behavior of the check function.

username_check

This function will check that the input only consists of characters and numbers and starts with a character.

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:

  1. (Flag 1 or 0) - Defines whether or not the first character MUST be a letter
  2. (Numeric) - Defines the minimum number of upper case characters there needs to be
  3. (Numeric) - Defines the minimum number of lower case characters there needs to be
  4. (Numeric) - Defines the minimum number of Numbers (0-9) there needs to be
  5. (Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check)
  6. (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:

  1. The first character must be a letter
  2. There must be at least 4 upper case letters
  3. There must be at least 9 lower case


password_check

This function will check that the input only consists of characters and numbers.

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:

  1. (Flag 1 or 0) - Defines whether or not the first character MUST be a letter.
  2. (Numeric) - Defines the minimum number of upper case characters there needs to be.
  3. (Numeric) - Defines the minimum number of lower case characters there needs to be.
  4. (Numeric) - Defines the minimum number of Numbers (0-9) there needs to be.
  5. (Numeric) - Defines the minimum number of Special Characters there needs to be (Anything that is not a letter or a number).
  6. (Flag 1 or 0) - Defines whether or not all characters MUST be upper case (This overrides the numeric lower case check).
  7. (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:

  1. The first character must be a letter
  2. There must be at least 5 Numeric Characters
  3. There must be at least 3 Special Characters
  4. Any Alphabetic characters must be uppercase

email_check

Checks the input using a regular expression to determine if it is a valid email. This function does not perform domain checking.

strong_email_check

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 called in this 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

substring_check

This check takes another input name as an argument. For example: signup[password:1:6:16:::password_check,substring_check;username] In the above example the password input will have the normal password_check run, then it will do the substring_check to ensure the password does not have a part that matches the username input.

url_check

Checks that the input is a valid URL.

not_numeric_check

Checks if the input contains any numbers.

alnum_check

Ensures input only consists of alphanumeric characters and underscores.

alnum_space_check

Ensures input only consists of alphanumeric characters, underscores, and spaces.

alnum_letter_check

Ensures input only consists of alphanumeric characters and underscores, and starts with a character.

alnum_letter_space_check

Ensures input only consists of alphanumeric characters, underscores, spaces, and starts with a character.

age_check

The iput for this check must be a date in the format of:
Y-m-d (1985-05-13)

The function will take this input as the birth date and compare the date to now, to determine the age of the user. The function will then compare the resulting age to your configuration setting "$config['MIN_AGE']". If the age of the user is less than the configuration, NATS will return an error:

"You have to be at least $config[MIN_AGE] years old to join!""

mod10_check

Uses the mod10 algorithm to check for a valid credit card number.