PHP jQuery form with verification
Email detection and password repeat detection can be used in various forms for sending environments, such as sending feedback and registering accounts
Demo
XML/HTML Code
-
-
-
-
-
-
- Invalid Name:We want names with more than 3 letters!
-
- Invalid E-mail:Stop cowboy! Type a valid e-mail please: P
-
- Passwords are invalid:Passwords doesn' t match or are invalid!
-
- Ivalid message:Type a message with at least with 10 letters
-
-
-
-
-
- Congratulations!All fields are OK ;)
-
-
-
-
Validation. php
PHP Code
- Function validateName ($ name ){
- // If it's NOT valid
- If (strlen ($ name) <4)
- Return false;
- // If it's valid
- Else
- Return true;
- }
- Function validateEmail ($ email ){
- Return ereg (^ [a-zA-Z0-9] + [a-zA-Z0-9 _-] + @ [a-zA-Z0-9] + [a-zA-Z0-9. -] + [a-zA-Z0-9] +. [a-z] {2, 4 }$, $ email );
- }
- Function validatePasswords ($ pass1, $ pass2 ){
- // If doesn' T MATCH
- If (strpos ($ pass1 ,'')! = False)
- Return false;
- // If are valid
- Return $ pass1 ==$ pass2 & strlen ($ pass1)> 5;
- }
- Function validateMessage ($ message ){
- // If it's NOT valid
- If (strlen ($ message) <10)
- Return false;
- // If it's valid
- Else
- Return true;
- }
- ?>