Clear form
Misc:
- /^[a-z]/ - checks first character only - allows all other characters
- /[a-z]\z/ - checks last character only - allows all other characters
- /^[a-z]{2,8}$/ - requires length of 2 to 8 characters
Email:
- /^[[a-zA-Z0-9_\-.]*@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/
Passwords:
- /^.*(?=.{6,20})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/ - requires one lower and one uppercase letter and one number, BUT allows all other characters
- /^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$/ - requires one lower, upper, and number, BUT does NOT allow any other characters
- the '\W' stands for any not word character
- the '\x7B-\xFF' is the hex version of a range of ascii characters found on foreign keyboards
- /^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\x22\x25\x27\x3c\x3e\x7B-\xFF]).{6,15}$/ - requires one lower, one upper, and one number PLUS most especial charactes EXCEPT " ' % '<' and '>'
- /^(?=.*\d).{4,8}$/ - must include at least one numeric digit
-
Name:
- /^[a-zA-Z0-9'\s,.-]{2,100}$/ - spent an hour figuring out that /^[a-zA-Z0-9'\s,.-]{2,100}$/ works and /^[a-zA-Z0-9\s,.-']{2,100}$/ does not
* IMPORTANT * Notice where the apostrophe is located
- you're better off to use the hex representation of the ascii character for a quote - \x27
Text:
- /^[a-zA-Z0-9\x27\s_~,-.=!?:+;@#$%^&*()|\/]{2,100}$/ - allows most general punctuation except '<' and '>' and double quotes
- to add double quotes, use the hex representation of them - \x22
- /[^A-Za-z0-9]/ - Reverse search - finds antying that is NOT alphanumeric
File Name
- /^[0-9A-Za-z_ -]+(.[jJ][pP][gG]|.[gG][iI][fF]|.[pP][nN][gG])$/ - accepts valid jpg, gif, ang png files