Regular post
1, the mail
Const isEmail = (v) = > {return / ^ ([a zA - Z0 - _ - 9]) + @ ([a zA - Z0 - _ - 9]) + ((. [a zA - Z0 - _ - 9] {2, 3})} {1, 2) $/. The test (v); };Copy the code
2. Mobile phone number
const isMobile = (v, isStrict = false) => { switch (isStrict) { case false: return /^1[0-9]{10}$/.test(v); case true: return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(v); default: return true; }};Copy the code
3. Landline number
Const isTel = (v, isStrict = false) => {switch (isStrict) {case false: return /^([0-9]{3,4}-)? [0-9] {7, 8} $/. The test (v); Case true: return / ^ (0 \ d {2, 3} - \ d {7, 8}) (\ d {1, 4})? $/.test(v); default: return true; }};Copy the code
4. Url address
const isURL = (v, isStrict = false) => { switch (isStrict) { case false: return /^http[s]? :\/\/.*/.test(v); case true: return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])? /.test(v); default: return true; }};Copy the code
5. Id card
const isIdcard = (v) => {
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(v);
};
Copy the code
6. Zip code
const isPostal = (v) => { return /[1-9]\d{5}(? ! \d)/.test(v); };Copy the code
7. Password verification
Const PSW = (v) => {// the password must start with a letter and must be 6 to 18 characters in length, including only letters, digits, and underscores (_). Return /^[a-za-z]\w{5,17}$/.test(v); };Copy the code
8. Amount (2 decimal places)
const money = (v) => { return /^\d*(? : \ \ d {0, 2})? $/.test(v); };Copy the code
9. Date and time
const isDate = (v) => { return ( /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(? :\:\d{2}|:(\d{2}):(\d{2}))$/.test(v) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(v) ); };Copy the code
10, Numbers,
const isNum = (v) => {
return /^[0-9]$/.test(v);
};
Copy the code
11, English
const isEnglish = (v) => {
return /^[a-zA-Z]+$/.test(v);
};
Copy the code
12, Chinese
const isChinese = (v) => {
return /^[\u4E00-\u9FA5]+$/.test(v);
};
Copy the code
13, lowercase
const isLower = (v) => {
return /^[a-z]+$/.test(v);
};
Copy the code
14 and the capital
const isUpper = (v) => {
return /^[A-Z]+$/.test(v);
};
Copy the code
15. HTML tags
const isHTML = (v) => {
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(v);
};
Copy the code
Type judgment
1. Whether it is a string
const isString = (v) => {
return (
typeof v == "string" &&
Object.prototype.toString.call(v).slice(8, -1) === "String"
);
};
Copy the code
2, whether the number
const isNumber = (v) => { return ( typeof v === "number" && ! isNaN(v) && Object.prototype.toString.call(v).slice(8, -1) === "Number" ); };Copy the code
3, whether Boolean
const isBoolean = (v) => {
return (
typeof v === "boolean" &&
Object.prototype.toString.call(v).slice(8, -1) === "Boolean"
);
};
Copy the code
4, whether function
const isFunction = (v) => {
return (
typeof v === "function" &&
Object.prototype.toString.call(v).slice(8, -1) === "Function"
);
};
Copy the code
5. Whether to null
const isNull = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "Null";
};
Copy the code
6, undefined
const isUndefined = (v) => {
return (
typeof v === "undefined" &&
Object.prototype.toString.call(v).slice(8, -1) === "Undefined"
);
};
Copy the code
7, whether the object
const isObj = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "Object";
};
Copy the code
8, whether the array
const isArray = (v) => {
return (
Array.isArray(v) &&
Object.prototype.toString.call(v).slice(8, -1) === "Array"
);
};
Copy the code
9, whether the time
const isDate = (v) => {
return (
v instanceof Date &&
Object.prototype.toString.call(v).slice(8, -1) === "Date"
);
};
Copy the code
10, whether regular
const isRegExp = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "RegExp";
};
Copy the code
11. Whether the object is wrong
const isError = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "Error";
};
Copy the code
12, whether the Symbol function
const isSymbol = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "Symbol";
};
Copy the code
13, whether the Promise object
const isPromise = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "Promise";
};
Copy the code
14. Whether to Set an object
const isSet = (v) => {
return Object.prototype.toString.call(v).slice(8, -1) === "Set";
};
Copy the code
=============== to be continued ================