Getting Started with JS Auto Form Validator

(for version 2.0.0 or above)

After you have JS AFV installed, you need to perform next steps:

[top]

Step 1. Connecting Submit button.


To connect your Submit button on the form to handler of validation process - just copy & paste these lines before your </form> tag, where form_name is a name of your form tag on the page.

There are 3 parameters in onSubmitCheck() function:

First parameter (required) - the name of form
Second parameter (optional, default - false) - handling all fields or handling each field separately
Third parameter (optional, default - false) - handling hidden fields or not

<input
   type="submit"
   name="button"
   value="Submit"
   onClick="return onSubmitCheck(document.forms['form_name'], false, false);" /> 


[top]

Step 2. Defining fields for validation.


To define fields for validation process, you need to give them a special prefix. If you don't want some field will be checked by form validator, just give to this field a name, started with "_", for example: "_email".

This special prefix combined from 3 letters, where:

    First letter: 
        r - required,      s - simple (not required)
    Second letter: 
        t - text(including datetime), 
        n - numeric,       a - alphanumeric, 
        e - email,         f - float, 
        y - any,           l - login name, 
        z - zipcode,       p - password, 
        i - integer,       v - verified, 
        u - URL
    Third letter (optional): 
        for numbers: s - signed, u - unsigned, p - positive, n - negative
        for strings: u - upper,  l - lower,    n - normal,   y - any
For example:
    <!-- this field will not be checked -->
    <input type="text" name="_postcode" value="" />
    
    <!-- required text field -->
    <input type="text" name="rty_username" value="" />
    <!-- required email field -->
    <input type="text" name="rey_email" value="" /> 
    <!-- non-required positive float number field -->
    <input type="text" name="sfp_price" value="" /> 

    etc.