12345678910111213141516171819202122232425262728293031323334 |
- /* 去除字符串中的特殊符号 */
- const queryStr = (str, title = '该符号不可输入!') => {
- const pattern = new RegExp(/[`$%^&()\=<>"{}|\/;'\\[\]·%……&——\={}|]/g);
- if (pattern.test(str) == true && title) wx.showToast({
- title,
- icon: "none"
- })
- return str.replace(pattern, '');
- }
- /* 校验手机号码 */
- const CheckPhoneNumber = (num, title = '请输入正确的11位手机号码!') => {
- const reg = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
- let isAllow = reg.test(num);
- if (!isAllow && title) wx.showToast({
- title,
- icon: "none"
- })
- return isAllow;
- }
- /* 校验邮箱 */
- const CheckEmail = (num, title = '请输入正确的邮箱格式!') => {
- const reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
- let isAllow = reg.test(num);
- if (!isAllow && title) wx.showToast({
- title,
- icon: "none"
- })
- return isAllow;
- }
- module.exports = {
- queryStr,
- CheckPhoneNumber,
- CheckEmail
- }
|