驗證手機號以及郵箱,密碼6-18位的字母加數字的方式 正則登錄方式

data() {
	return {
		username: "",
		passwords: "",
	}
},
// 登陸的接口
	login() {
		let mobileReg = /^1(3|4|5|7|8|9)\d{9}$/; //手機號
		let emailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/; //郵箱
		let codeReg = /(?!^(\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\w~!@#$%^&*?]{6,16}$/ //密碼
		if (!this.username) {
			this.$toast('請填寫手機號或郵箱');
		} else if (!mobileReg.test(this.username) && !emailReg.test(this.username)) {
			this.$toast('手機號或郵箱格式不正確');
		} else if (this.passwords == "") {
			this.$toast('請輸入登錄密碼');
		} else if (!codeReg.test(this.passwords)) {
			this.$toast('請輸入正確的密碼');
		} else {
			this.show = true; //爲true時顯示彈框
		}
	},
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章