在我的html中有这样的输入:
<input class"email_address_input" required type="email" id="emailAddress" />
我正在尝试使用regex进行验证:
function ContactUs($el){
this.$el = $el;
this.$emailAddress = this.$el.find('#emailAddress');
this.emailValid();
return this;
}
ContactUs.prototype.isEmail = function(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
ContactUs.prototype.emailValid = function($el) {
var THIS = this;
if (THIS.$emailAddress.val().length) {
THIS.isEmail(THIS.$emailAddress);
}
return THIS;
}
我得到的所有是false
,即使我把一个有效的电子邮件格式。
怎么了?
https://stackoverflow.com/questions/41111948
复制相似问题