Simple php verification-php Tutorial

Source: Internet
Author: User
Php verification is very simple. please give it a piece of code. I know it is very simple, but I have tried a lot of methods, either do not jump or do not move. It cannot be implemented. is implemented: Enter the zip code in the input box, and then verify that if it is 5 digits, it will jump to the next page. if it is not 5, it will stay in the original page and add "Wrong Zip Code" after the input box ". thank you. ------ solution ----------- very simple php verification.
Please refer to the code section. I know it is very simple, but I have tried many methods, either not to jump or to remain unchanged. It cannot be implemented.
Is implemented: Enter the zip code in the input box, and then verify that if it is 5 digits, it will jump to the next page. if it is not 5, it will stay in the original page and add "Wrong Zip Code" after the input box ".
Thank you.


------ Solution --------------------
Script
Function iszipcode (object)
{
Var s = document. getElementById (object. id). value;
Var pattern =/^ [0-9] {6} $ /;
If (s! = "")
{
If (! Pattern.exe c (s ))
{
Alert ('Enter the correct postal code ');
Object. value = "";
Object. focus ();
}
}
}

Script

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.