PHPjQuery form with verification implementation method _ php instance

Source: Internet
Author: User
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;
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.