Vue郵箱驗(yàn)證刻肄,身份證驗(yàn)證瓤球,電話驗(yàn)證。敏弃。卦羡。

1,郵箱驗(yàn)證


sendEmail(){

let self = this;

var regEmail = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;

if (self.listdata.productionStatus != '' && !regEmail.test(self.listdata.productionStatus)) {

self.$message({ message: '郵箱格式不正確', type: 'error' })

self.listdata.productionStatus = '' }},

2麦到,手機(jī)號(hào)驗(yàn)證


sendCode(){

let self = this;

var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;

if(!reg.test(self.listdata.phone)){

self.$message({ message: '手機(jī)號(hào)格式不正確', type: 'error' })

self.listdata.phone = '' }},

3绿饵,身份證驗(yàn)證

? ? 1.引入js? ? idCard.js

? ? 2.main.js中引入

????????import IdCard from './assets/js/idCard'

????????Vue.prototype.validid = IdCard;

js

idcarno(){

let self = this;

self.validid.cnid(self.listdata.taxNature);

if(self.validid.cnid(self.listdata.taxNature) == true){

}else{

self.$message({ message: '身份證信息不正確,請(qǐng)從新輸入', type: 'error' })

self.listdata.taxNature = '' }},

? ? IdCart.js

//Generated by CoffeeScript 1.12.7 /*

Validid is open source in: https://github.com/Edditoria/validid under MIT license: https://github.com/Edditoria/validid/blob/master/LICENSE.md */ (function () { var Validid, validid; Validid = (function () { function Validid() { } Validid.prototype.tools = { normalize: function (id) { var re; re = /[-\/\s]/g; id = id.toUpperCase().replace(re, ''); re = /\([A-Z0-9]\)$/; if (re.test(id)) { id = id.replace(/[\(\)]/g, ''); } return id; }, isDateValid: function (idDate, minDate, maxDate) { var isFormatValid, parseDate; if (minDate == null) { minDate = 'default'; } if (maxDate == null) { maxDate = 'today'; } if (minDate === 'default' || minDate === '') { minDate = '18991129'; } isFormatValid = function (date) { return typeof date === 'string' && /^[0-9]{8}$/.test(date); }; if (!isFormatValid(idDate)) { return false; } if (!isFormatValid(minDate)) { return false; } parseDate = function (input) { var date, day, isDayValid, isFutureDate, isLeapYear, isMonthValid, maxDay, month, startIndex, year; startIndex = 0; year = +input.substring(startIndex, startIndex += 4); month = input.substring(startIndex, startIndex += 2); day = +input.substring(startIndex, startIndex += 2); date = new Date(year, +month - 1, day); maxDay = '01,03,05,07,08,10,12'.indexOf(month) >= 0 ? 31 : '04,06,09,11'.indexOf(month) >= 0 ? 30 : (isLeapYear = (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0), isLeapYear ? 29 : 28); isDayValid = day > 0 && day <= maxDay; if (!isDayValid) { return false; } isMonthValid = +month > 0 && +month <= 12; if (!isMonthValid) { return false; } isFutureDate = new Date() < date; if (isFutureDate) { return false; } return date; }; idDate = parseDate(idDate); if (idDate === false) { return false; } minDate = parseDate(minDate); if (minDate === false) { return false; } maxDate = maxDate === 'today' ? new Date() : typeof maxDate === 'string' ? parseDate(maxDate) : maxDate; if (maxDate === false) { return false; } return (idDate >= minDate) && (idDate <= maxDate); }, getMaxDate: function (yearsOld) { var now, year; now = new Date(); year = now.getFullYear() - yearsOld; return new Date(year, now.getMonth(), now.getDate()); } }; Validid.prototype.cnid = function (id) { var isChecksumValid, isDateValid, isFormatValid, isLengthValid; isLengthValid = function (id) { return id.length === 18; }; isFormatValid = function (id) { return /^[0-9]{17}[0-9X]$/.test(id); }; isDateValid = (function (_this) { return function () { return _this.tools.isDateValid(id.substring(6, 14), '18860625'); }; })(this); isChecksumValid = function (id) { var char, checkDigit, getWeight, i, identifier, index, len, remainder, weightedSum; identifier = id.slice(0, -1); checkDigit = id.slice(-1) === 'X' ? 10 : +id.slice(-1); getWeight = function (n) { return Math.pow(2, n - 1) % 11; }; weightedSum = 0; index = id.length; for (i = 0, len = identifier.length; i < len; i++) { char = identifier[i]; weightedSum += +char * getWeight(index); index--; } remainder = (12 - weightedSum % 11) % 11 - checkDigit; return remainder === 0; }; id = this.tools.normalize(id); return isLengthValid(id) && isFormatValid(id) && isDateValid() && isChecksumValid(id); }; Validid.prototype.twid = function (id) { var isChecksumValid, isFormatValid, isLengthValid; isLengthValid = function (id) { return id.length === 10; }; isFormatValid = function (id) { return /^[A-Z][12][0-9]{8}$/.test(id); }; isChecksumValid = function (id) { var char, i, idLen, idTail, len, letterIndex, letterValue, letters, remainder, weight, weightedSum; idLen = id.length; letters = 'ABCDEFGHJKLMNPQRSTUVXYWZIO'; letterIndex = letters.indexOf(id[0]) + 10; letterValue = Math.floor(letterIndex / 10) + (letterIndex % 10) * (idLen - 1); idTail = id.slice(1); weight = idLen - 2; weightedSum = 0; for (i = 0, len = idTail.length; i < len; i++) { char = idTail[i]; weightedSum += +char * weight; weight--; } remainder = (letterValue + weightedSum + +id.slice(-1)) % 10; return remainder === 0; }; id = this.tools.normalize(id); return isLengthValid(id) && isFormatValid(id) && isChecksumValid(id); }; Validid.prototype.hkid = function (id) { var getLetterValue, isChecksumValid, isFormatValid, isLengthValid, isLetter; getLetterValue = function (letter) { return letter.charCodeAt(0) - 64; }; isLetter = function (char) { return /[a-zA-Z]/.test(char); }; isLengthValid = function (id) { return id.length === 8 || id.length === 9; }; isFormatValid = function (id) { return /^[A-MP-Z]{1,2}[0-9]{6}[0-9A]$/.test(id); }; isChecksumValid = function (id) { var char, charValue, checkDigit, i, identifier, len, remainder, weight, weightedSum; weight = id.length; weightedSum = 0; identifier = id.slice(0, -1); checkDigit = id.slice(-1) === 'A' ? 10 : +id.slice(-1); for (i = 0, len = identifier.length; i < len; i++) { char = identifier[i]; charValue = isLetter(char) ? getLetterValue(char) : +char; weightedSum += charValue * weight; weight--; } remainder = (weightedSum + checkDigit) % 11; return remainder === 0; }; id = this.tools.normalize(id); return isLengthValid(id) && isFormatValid(id) && isChecksumValid(id); }; Validid.prototype.krid = function (id) { var isChecksumValid, isDateValid, isFormatValid, isLengthValid; isLengthValid = function (id) { return id.length === 13; }; isFormatValid = function (id) { return /^[0-9]{13}$/.test(id); }; isDateValid = (function (_this) { return function (id) { var date, maxDate, sDigit, yearPrefix; sDigit = id.substring(6, 7); yearPrefix = (function () { switch (sDigit) { case '1': case '2': case '5': case '6': return '19'; case '3': case '4': case '7': case '8': return '20'; default: return '18'; } })(); date = yearPrefix + id.substring(0, 6); maxDate = _this.tools.getMaxDate(17); return _this.tools.isDateValid(date, 'default', maxDate); }; })(this); isChecksumValid = function (id) { var char, i, index, len, remainder, weight, weightedSum; weight = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 0]; weightedSum = 0; index = 0; for (i = 0, len = id.length; i < len; i++) { char = id[i]; weightedSum += +char * weight[index]; index++; } remainder = (11 - weightedSum % 11) % 10 - +id.slice(-1); return remainder === 0; }; id = this.tools.normalize(id); return isLengthValid(id) && isFormatValid(id) && isDateValid(id) && isChecksumValid(id); }; return Validid; })(); validid = new Validid(); if ((typeof module !== "undefined" && module !== null) && module.exports) { module.exports = validid; } if (typeof window !== "undefined" && window !== null) { window.validid = validid; }}).call(this);

? ??

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市瓶颠,隨后出現(xiàn)的幾起案子拟赊,更是在濱河造成了極大的恐慌,老刑警劉巖粹淋,帶你破解...
    沈念sama閱讀 217,277評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件吸祟,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡廓啊,警方通過查閱死者的電腦和手機(jī)欢搜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,689評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來谴轮,“玉大人,你說我怎么就攤上這事吹埠〉诓剑” “怎么了疮装?”我有些...
    開封第一講書人閱讀 163,624評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)粘都。 經(jīng)常有香客問我廓推,道長(zhǎng),這世上最難降的妖魔是什么翩隧? 我笑而不...
    開封第一講書人閱讀 58,356評(píng)論 1 293
  • 正文 為了忘掉前任樊展,我火速辦了婚禮,結(jié)果婚禮上堆生,老公的妹妹穿的比我還像新娘专缠。我一直安慰自己,他們只是感情好淑仆,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,402評(píng)論 6 392
  • 文/花漫 我一把揭開白布涝婉。 她就那樣靜靜地躺著,像睡著了一般蔗怠。 火紅的嫁衣襯著肌膚如雪墩弯。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,292評(píng)論 1 301
  • 那天寞射,我揣著相機(jī)與錄音渔工,去河邊找鬼。 笑死桥温,一個(gè)胖子當(dāng)著我的面吹牛引矩,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播策治,決...
    沈念sama閱讀 40,135評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼脓魏,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了通惫?” 一聲冷哼從身側(cè)響起茂翔,我...
    開封第一講書人閱讀 38,992評(píng)論 0 275
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎履腋,沒想到半個(gè)月后珊燎,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,429評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡遵湖,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,636評(píng)論 3 334
  • 正文 我和宋清朗相戀三年悔政,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片延旧。...
    茶點(diǎn)故事閱讀 39,785評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡谋国,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出迁沫,到底是詐尸還是另有隱情芦瘾,我是刑警寧澤捌蚊,帶...
    沈念sama閱讀 35,492評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站近弟,受9級(jí)特大地震影響缅糟,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜祷愉,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,092評(píng)論 3 328
  • 文/蒙蒙 一窗宦、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧二鳄,春花似錦赴涵、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,723評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至躯嫉,卻和暖如春纱烘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背祈餐。 一陣腳步聲響...
    開封第一講書人閱讀 32,858評(píng)論 1 269
  • 我被黑心中介騙來泰國(guó)打工擂啥, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人帆阳。 一個(gè)月前我還...
    沈念sama閱讀 47,891評(píng)論 2 370
  • 正文 我出身青樓哺壶,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親蜒谤。 傳聞我的和親對(duì)象是個(gè)殘疾皇子山宾,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,713評(píng)論 2 354