PHP jQuery form with verification

Source: Internet
Author: User

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
  1.  
  2.  
  3.  
  4.  
    •  
    • 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
    •  
  5.  
  6.  
    •  
    • Congratulations!All fields are OK ;)
    •  
  7.  
  8.  
  9. Validation. php

     

    PHP Code
    1. Function validateName ($ name ){
    2. // If it's NOT valid
    3. If (strlen ($ name) <4)
    4. Return false;
    5. // If it's valid
    6. Else
    7. Return true;
    8. }
    9. Function validateEmail ($ email ){
    10. 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 );
    11. }
    12. Function validatePasswords ($ pass1, $ pass2 ){
    13. // If doesn' T MATCH
    14. If (strpos ($ pass1 ,'')! = False)
    15. Return false;
    16. // If are valid
    17. Return $ pass1 ==$ pass2 & strlen ($ pass1)> 5;
    18. }
    19. Function validateMessage ($ message ){
    20. // If it's NOT valid
    21. If (strlen ($ message) <10)
    22. Return false;
    23. // If it's valid
    24. Else
    25. Return true;
    26. }
    27. ?>

       

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.