Home Web Front-end JS Tutorial Examples of regular verification of mobile phone number, email address, ID card, and bank card

Examples of regular verification of mobile phone number, email address, ID card, and bank card

Jul 03, 2017 pm 02:15 PM
phone number E-mail bank card

手机号码:

var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
Copy after login

电子邮箱:

/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/i
Copy after login

身份证:

var isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;var isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
Copy after login

银行卡:

function luhmCheck(bankno){var lastNum=bankno.substr(bankno.length-1,1);//取出最后一位(与luhm进行比较)var first15Num=bankno.substr(0,bankno.length-1);//前15或18位var newArr=new Array();for(var i=first15Num.length-1;i>-1;i--){    //前15或18位倒序存进数组newArr.push(first15Num.substr(i,1));
        }var arrJiShu=new Array();  //奇数位*2的积 <9var arrJiShu2=new Array(); //奇数位*2的积 >9var arrOuShu=new Array();  //偶数位数组for(var j=0;j<newArr.length;j++){if((j+1)%2==1){//奇数位if(parseInt(newArr[j])*2<9)
                    arrJiShu.push(parseInt(newArr[j])*2);elsearrJiShu2.push(parseInt(newArr[j])*2);
            }else //偶数位                arrOuShu.push(newArr[j]);
        }var jishu_child1=new Array();//奇数位*2 >9 的分割之后的数组个位数var jishu_child2=new Array();//奇数位*2 >9 的分割之后的数组十位数for(var h=0;h<arrJiShu2.length;h++){
            jishu_child1.push(parseInt(arrJiShu2[h])%10);
            jishu_child2.push(parseInt(arrJiShu2[h])/10);        }var sumJiShu=0; //奇数位*2 < 9 的数组之和var sumOuShu=0; //偶数位数组之和var sumJiShuChild1=0; //奇数位*2 >9 的分割之后的数组个位数之和var sumJiShuChild2=0; //奇数位*2 >9 的分割之后的数组十位数之和var sumTotal=0;for(var m=0;m<arrJiShu.length;m++){
            sumJiShu=sumJiShu+parseInt(arrJiShu[m]);
        }for(var n=0;n<arrOuShu.length;n++){
            sumOuShu=sumOuShu+parseInt(arrOuShu[n]);
        }for(var p=0;p<jishu_child1.length;p++){
            sumJiShuChild1=sumJiShuChild1+parseInt(jishu_child1[p]);
            sumJiShuChild2=sumJiShuChild2+parseInt(jishu_child2[p]);
        }//计算总和sumTotal=parseInt(sumJiShu)+parseInt(sumOuShu)+parseInt(sumJiShuChild1)+parseInt(sumJiShuChild2);//计算Luhm值var k= parseInt(sumTotal)%10==0?10:parseInt(sumTotal)%10;var luhm= 10-k;if(lastNum==luhm){return true;
        }else{return false;
        }
    }
Copy after login

 

The above is the detailed content of Examples of regular verification of mobile phone number, email address, ID card, and bank card. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is hotmail? What is hotmail? Oct 28, 2022 pm 03:15 PM

Hotmail is a free Internet email service launched by Microsoft. It is one of the free Internet email providers. Anyone in the world can read it and send and receive emails through a web browser. Hotmail was acquired by Microsoft at the end of 1997 for a huge sum of US$400 million, and gradually transitioned from running on the FreeBSD platform to running entirely on the Windows platform.

What are the reasons why a mobile phone has an empty number? What are the reasons why a mobile phone has an empty number? Feb 21, 2023 pm 02:26 PM

The reasons why the mobile phone number is empty: 1. The mobile phone number has been blacklisted by the other party; 2. The other party has set up the call transfer function, and the transferred number is an unconventional mobile phone number range, such as 11 digits pressed randomly; 3. The number is wrong ; 4. Virtual number; 5. The number has been canceled and is in the recovery freezing period; 6. The operator's system failure will cause the user's mobile phone to have an empty number in a regional and range manner; 7. The signal is not good; 8. The number The format is wrong; 9. Mobile phone card failure; 10. Special ringtone.

What is the email address of @163.com? What is the email address of @163.com? Oct 17, 2022 pm 03:17 PM

"@163.com" refers to the 163 free email address owned by NetEase, and its format is "username plus @163.com". 163 Mailbox is a classic work of China's early email service provider NetEase, which is committed to providing users with safe, stable, fast and convenient email services; the birth of 163 Mailbox has provided a platform for NetEase Mailbox to later incubate a series of products such as 126 and yeah The mailbox system laid the foundation and paved the way for NetEase to become the future mailbox overlord. It also provided a huge user base for NetEase's series of products and services such as portals and games.

What is the difference between hotmail and outlook? What is the difference between hotmail and outlook? Oct 31, 2022 pm 05:07 PM

Differences: 1. Outlook focuses on business use, while Hotmail is geared toward individual users; 2. Outlook is one of the components of Microsoft’s office software suite, while Hotmail is one of the free email providers on the Internet. Anyone in the world can use a web browser to Read it and send and receive emails; 3. Outlook has more functions than hotmail. You can use Outlook to send and receive emails, manage contact information, keep diaries, arrange schedules, and assign tasks.

How to check what is registered with a mobile phone number 'Detailed explanation: APP query method for mobile phone number registration' How to check what is registered with a mobile phone number 'Detailed explanation: APP query method for mobile phone number registration' Feb 07, 2024 am 08:24 AM

I don’t know if you have such an experience. Your mobile phone often receives some inexplicable text messages, or registration information for some websites or other verification information. In fact, our mobile phone number may be bound to many unfamiliar websites, and we ourselves Even if you don’t know, what I will share with you today is to teach you how to unbind all unfamiliar websites with one click. Step 1: Open the number service platform. This technique is very practical. The steps are as follows: Open WeChat, click the plus icon in the search box, select Add Friend, and then enter the code number service platform to search. We can see that there is a number service platform. Of course, it belongs to a public institution and was launched by the National Institute of Information and Communications Technology. It can help everyone unbind mobile phone number information with one click. Step 2: Check whether the phone has been marked for me

Can two WeChat accounts be bound to the same bank card? Can two WeChat accounts be bound to the same bank card? Aug 25, 2023 pm 03:13 PM

Two WeChat accounts cannot be bound to the same bank card. Bind a bank card to a WeChat account: 1. Open the WeChat application, click the "Me" option, and then select the "Pay" option; 2. Select the "Add Bank Card" option and enter the bank card information as prompted; 3. Once the bank card is successfully bound, users can use the bank card to make payments and transfers in WeChat.

What is the suffix of Google Email? What is the suffix of Google Email? Feb 27, 2023 pm 02:00 PM

There are two suffixes for Google mailboxes: "@gmail.com" and "@googlemail.com". "@gmail.com" is the main email suffix, and "@googlemail.com" is a backup email suffix set in response to restrictions on Google Mail users in some countries/regions. Google Mail, also known as Gmail, is a webmail service produced by Google. It comes with built-in Google search technology and provides more than 15G of storage space.

What is the email address of .cn? What is the email address of .cn? Sep 13, 2022 am 11:30 AM

A ".cn" email is an email that ends with ".cn" as the domain name suffix, and the cn domain name refers to the domain name registered in China; the domain name is a computer or computer on the Internet consisting of a string of names separated by dots. The name of a computer group, used to identify the electronic location of a computer during data transmission. cn is the domain name of the People's Republic of China, used on the Internet in mainland China.

See all articles