Skip to content

Commit 076a6a4

Browse files
committed
update
1 parent 380fb26 commit 076a6a4

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// 验证邮箱
1+
###### 验证邮箱
2+
````js
23
export function checkEmail (val) {
34
val = trimSpace(val)
45
let reg = new RegExp('^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$')
@@ -8,8 +9,10 @@ export function checkEmail (val) {
89
return false
910
}
1011
}
12+
````
1113

12-
// 验证手机号
14+
###### 验证手机号
15+
````js
1316
export function checkPhoneNumber (val) {
1417
val = trimSpace(val)
1518
let reg = new RegExp('^(((13[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(15[0-3]{1})|(15[4-9]{1})|(18[0-9]{1})|(199))+\\d{8})$')
@@ -19,26 +22,32 @@ export function checkPhoneNumber (val) {
1922
return false
2023
}
2124
}
25+
````
2226

23-
// 去除字符串前后空格
27+
###### 去除字符串前后空格
28+
````js
2429
export function trimSpace (str) {
2530
if (str) {
2631
return str.replace(/(^\s*)|(\s*$)/g, '')
2732
} else {
2833
return str
2934
}
3035
}
36+
````
3137

32-
// 去除字符串所有空格
38+
###### 去除字符串所有空格
39+
````js
3340
export function trimAllSpace (str) {
3441
if (str) {
3542
return str.replace(/\s+/g, "")
3643
} else {
3744
return str
3845
}
3946
}
47+
````
4048

41-
// 图片的预加载
49+
###### 图片的预加载
50+
````js
4251
export function preloadImg (srcArr) {
4352
if (srcArr instanceof Array) {
4453
for (var i = 0; i < srcArr.length; i++) {
@@ -47,28 +56,36 @@ export function preloadImg (srcArr) {
4756
}
4857
}
4958
}
59+
````
5060

51-
// 验证密码,密码为6-12位字母数字或符号最少两种组合,特殊符号为 ~!@#$%^&*.,
61+
###### 验证密码,密码为6-12位字母数字或符号最少两种组合
62+
````js
63+
// 特殊符号为 ~!@#$%^&*.,
5264
export function verifyPassword (str) {
5365
str = trimSpace(str)
5466
let RegExp = /((?=.*[a-z])(?=.*\d)|(?=.*[a-z])(?=.*[~!@#$%^&*.,])|(?=.*\d)(?=.*[~!@#$%^&*.,]))[a-z\d~!@#$%^&*.,]{6,12}/i
5567
return RegExp.test(str)
5668
}
69+
````
5770

58-
// 仅允许输入正整数
71+
###### 仅允许输入正整数
72+
````js
5973
export function positiveInteger (_this) {
6074
if (_this.value.length === 1) {
6175
_this.value = _this.value.replace(/[^1-9]/g, '')
6276
} else {
6377
_this.value = _this.value.replace(/\D/g, '')
6478
}
6579
}
80+
````
6681

67-
// 仅允许输入负整数
82+
###### 仅允许输入负整数
83+
````js
6884
export function negativeInteger (_this) {
6985
if (_this.value.length === 1) {
7086
_this.value = _this.value.replace(/[^\-]/g, '-')
7187
} else {
7288
_this.value = _this.value.replace(/[^\d-]/g, '')
7389
}
74-
}
90+
}
91+
````

Diff for: README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* <details>
1616
<summary>Form表单验证常用方法</summary>
1717

18-
- [验证邮箱](/Native-JavaScript/form-validator.js)
19-
- [验证手机号](/Native-JavaScript/form-validator.js)
20-
- [去除字符串前后空格](/Native-JavaScript/form-validator.js)
21-
- [去除字符串所有空格](/Native-JavaScript/form-validator.js)
22-
- [图片的预加载](/Native-JavaScript/form-validator.js)
23-
- [验证密码,密码为6-12位字母数字或符号最少两种组合,特殊符号为 ~!@#$%^&*.,](/Native-JavaScript/form-validator.js)
24-
- [仅允许输入正整数](/Native-JavaScript/form-validator.js)
25-
- [仅允许输入负整数](/Native-JavaScript/form-validator.js)
18+
- [验证邮箱](/Native-JavaScript/form-validator.md#验证邮箱)
19+
- [验证手机号](/Native-JavaScript/form-validator.md#验证手机号)
20+
- [去除字符串前后空格](/Native-JavaScript/form-validator.md#去除字符串前后空格)
21+
- [去除字符串所有空格](/Native-JavaScript/form-validator.md#去除字符串所有空格)
22+
- [图片的预加载](/Native-JavaScript/form-validator.md#图片的预加载)
23+
- [验证密码,密码为6-12位字母数字或符号最少两种组合,特殊符号为 ~!@#$%^&*.,](/Native-JavaScript/form-validator.md#验证密码,密码为6-12位字母数字或符号最少两种组合)
24+
- [仅允许输入正整数](/Native-JavaScript/form-validator.md#仅允许输入正整数)
25+
- [仅允许输入负整数](/Native-JavaScript/form-validator.md#仅允许输入负整数)
2626
</details>
2727

2828
* <details>

0 commit comments

Comments
 (0)