# 优化用户名验证

This commit is contained in:
xianfuxing 2021-05-11 15:52:30 +08:00
parent ce22ad34ab
commit 44558bc751
1 changed files with 1 additions and 1 deletions

View File

@ -5,7 +5,7 @@
export function isvalidUsername(str) {
// const valid_map = ['xianfuxing', 'editor']
// return valid_map.indexOf(str.trim()) >= 0
const usernameRegex = /^(?![0-9]+$)[0-9A-Za-z]{4,}$/
const usernameRegex = /^(?![0-9]+$)[0-9A-Za-z_]{4,}$/
return usernameRegex.test(str)
}