This article mainly introduces PHPjQuery forms with verification implementation methods. If you need them, you can refer to the e-mail detection and password repeat detection, which can be used in various forms for sending environments, such as sending feedback, register an account
The Code is as follows:
- 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
The Code is as follows:
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;
}
?>