当前位置:网站首页>9 - regular check set
9 - regular check set
2022-06-30 02:02:00 【Wine tripod】
Commonly used regular
In project development , some input( Input ) Box needs to be verified , Whether the input content is legal ; Here are some common Regular check .
// Regular check modularization
export default {
data() {
return {
rules: {
/* 1, The password must be by 10 To 16 Digit number 、 Upper and lower case letters and special symbols */
passwordReg: [
{
required: true, message: ' Please input a password ', trigger: 'blur' },
{
pattern: /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*)(?=.*[[email protected]#$%^&*_].*).{10,16}$/, message: ' Incorrect format ' },
],
/* 2, Unified social credit code */
unifiedSocialCreditCodeReg: [
{
required: true, message: ' Please enter the unified social credit code ', trigger: 'blur' },
{
pattern: /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/, message: ' Incorrect format ' },
],
/* 3, Taxpayer identification number */
ITINReg: [
{
required: true, message: ' Please enter the unified social credit code ', trigger: 'blur' },
{
pattern: /[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}/, message: ' Incorrect format ' },
],
/* 4, cell-phone number */
mobileReg: [
{
required: true, message: ' Please enter your mobile number ', trigger: 'blur' },
{
pattern: /^1[34578]\d{9}$/, message: ' Incorrect format ' },
],
/* 5, Landline */
specialPlaneReg: [
{
required: true, message: ' Please enter the landline number ', trigger: 'blur' },
{
pattern: /^(0[0-9]{2,3}\-)([2-9][0-9]{4,7})+(\-[0-9]{1,4})?$/, message: ' Incorrect format ' },
],
/* 6, Illegal number */
unallowableDigitReg: [
{
required: true, message: ' Please enter a number ', trigger: 'blur' },
{
pattern: /^\d+$|^\d+[.]?\d+$/, message: ' Illegal number ' },
],
/* 7, It has to be numbers */
figureReg: [
{
required: true, message: ' Please enter a number ', trigger: 'blur' },
{
pattern: /^[0-9][0-9]*([.][0-9]+)?$/, message: ' It has to be numbers ' },
],
/* 8, Id card */
identityCardReg: [
{
required: true, message: ' Please input ID card number ', trigger: 'blur' },
{
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: ' Incorrect format ' },
],
/* 9, mailbox */
mailboxReg: [
{
required: true, message: ' Please enter email address ', trigger: 'blur' },
{
pattern: /^([a-zA-Z0-9_-])[email protected]([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/, message: ' Incorrect format ' },
],
/* 10, WeChat */
wxReg: [
{
required: true, message: ' Please input the micro signal ', trigger: 'blur' },
{
pattern: /^[a-zA-Z0-9]{1}[-_a-zA-Z0-9]{4,19}$/, message: ' Incorrect format ' },
],
/* 11, Integers */
integerReg: [
{
required: true, message: ' please enter an integer ', trigger: 'blur' },
{
pattern: /^([0]|[1-9][0-9]*)$/, message: ' Incorrect format ' },
],
/* 12, Effective amount */
validMoneyReg: [
{
required: true, message: ' Please enter a valid amount ', trigger: 'blur' },
{
pattern: /^[1-9][0-9]*([.][0-9]+)?$/, message: ' Incorrect format ' },
],
/* 13, Hong Kong macau pass */
HKReg: [
{
required: true, message: ' Please enter the Hong Kong and Macao pass number ', trigger: 'blur' },
{
pattern: /^[CW]\d{8}$/, message: ' Incorrect format ' },
],
/* 14, Taiwan pass */
TWReg: [
{
required: true, message: ' Please enter the Taiwan pass number ', trigger: 'blur' },
{
pattern: /^[a-zA-Z][0-9]{9}$/, message: ' Incorrect format ' },
],
/* 15, passport */
passportReg: [
{
required: true, message: ' Please enter your passport number ', trigger: 'blur' },
{
pattern: /^1[45][0-9]{7}$|([P|p|S|s]\d{7}$)|([S|s|G|g]\d{8}$)|([Gg|Tt|Ss|Ll|Qq|Dd|Aa|Ff]\d{8}$)|([H|h|M|m]\d{8,10})$/, message: ' Incorrect format ' },
],
/* 16, Bank card number */
cardNoReg: [
{
required: true, message: ' Please enter your bank card number ', trigger: 'blur' },
{
pattern: /^([0-9]{1})(\d{9,29})$/, message: ' Incorrect format ' },
],
/* 17, The input contains special symbols */
specialCharacterReg: [
{
required: true, message: ' Please enter the content ', trigger: 'blur' },
{
pattern: /^([0-9]{1})(\d{9,29})$/, message: ' The input contains special symbols ' },
],
/* 18, Including Chinese */
ContainsChineseReg: [
{
required: true, message: ' Please enter the content ', trigger: 'blur' },
{
pattern: /[\u4E00-\u9FA5]/, message: ' The input content contains Chinese ' },
],
/* 19, Zip code */
postCodeReg: [
{
required: true, message: ' Please enter the content ', trigger: 'blur' },
{
pattern: /^\d{6}$/, message: ' Incorrect format ' },
],
/* 20, The business license 、 Organization code */
businessLicenseReg: [
{
required: true, message: ' Please enter the content ', trigger: 'blur' },
{
pattern: /^[a-zA-Z0-9]{10,20}$/, message: ' Incorrect format ' },
],
/* 21, Tax registration certificate */
taxRegistrationCertificateReg: [
{
required: true, message: ' Please enter the content ', trigger: 'blur' },
{
pattern: /^[0-9a-zA-z_]{10,20}$/, message: ' Incorrect format ' },
],
},
};
},
};
Regular modularity
- Regular in a js The document defines ;( The above code is an example )
- Use... In required components
mixinsMix into components ;
import rules from "@/mixins/regular-modularization.js";
export default {
name: "vueRegularModularization",
mixins: [rules],
data() {
return {
ruleForm: {
mobileReg: "",
},
};
},
}
- Components using regular .
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" >
边栏推荐
- 假离婚变成真离婚,财产怎么办
- UE5的蓝图节点拷贝到UE4后连线和属性值全部丢失了
- AI landing manufacturing: intelligent robots should have these four abilities
- Cookie encryption 13
- 004_ icon
- 什么是幂等性?四种接口幂等性方案详解!
- 013_ slider
- 封装一个完整版的uniapp图片和视频上传组件,拿来即用,可进行图片视频切换,可自定义上传按钮样式,删除按钮样式,可单独上传图片或者视频,可限制上传数量
- Varnish foundation overview 2
- Circular right shift of array elements in C language
猜你喜欢

JS reverse request parameter encryption:

C language score ranking

Matlab 2012a 绘制带箭头的线段

DMX的配置

Unity2d-- add keys to animation and bind events

Cookie encryption 13

Cookie encryption 11

Thinking carefully and fearfully: a software can be transmitted online to monitor whether employees want to "run away"

Understand AQS principle (flow chart and synchronous queue diagram)
![[MySQL 05] SUSE 12 SP5 modifies the MySQL password for the first time after installing MySQL](/img/37/d24c9e5fad606d2623900ad018b6af.png)
[MySQL 05] SUSE 12 SP5 modifies the MySQL password for the first time after installing MySQL
随机推荐
Conjecture of prime pairs in C language
CTF入门学习(Web方向)
7 — filter
Fake divorce turns into real divorce. What about property
What should be paid attention to in the design and production of the Urban Planning Museum
Cookie encryption 12
Varnish foundation overview 7
The first technology podcast month will begin soon
Three questions from the boss
A summary of the quantification of deep network model
MySQL monitoring 1
018_ rate
Thinking carefully and fearfully: a software can be transmitted online to monitor whether employees want to "run away"
006_ radio
005_ button
Pytorch中transforms的用法整理
Where can I find a pre training model for pytoch model training?
Electron FAQ 54 - make your own fireworks based on electron
Pytorch 修改hook源码 获取Per-Layer输出参数(带layer name)
Method of converting songs from DTS to MP3