/**
*
* 過濾特殊字元
*/
export var checkObject = function () {
return {
//過濾特殊字元
stripscript: function (s) {
var pattern = new RegExp("[` ~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
var rs = "";
for (var i = 0; i < s.length; i++) {
rs = rs + s.substr(i, 1).replace(pattern, '');
}
return rs;
},
//驗證郵箱
checkEmail: function (value) {
let reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
return reg.test(value) ? false : true
},
//驗證密碼
checkPassword: function (value) {
let reg = /^[a-zA-Z]\w{5,19}$/;
return reg.test(value) ? false : true
},
//驗證驗證碼
checkCode: function (value) {
let reg = /^[a-zA-Z0-9]{6}$/;
return reg.test(value) ? false : true
}
}
}
var validate = checkObeject();
validate.check.stripscript()
validate.check.checkEmail()
validate.check.checkPassword()
validate.check.checkCode()