Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Created May 30, 2014 10:15
Show Gist options
  • Save alanerzhao/a51f6f61f7c5ee38ae82 to your computer and use it in GitHub Desktop.
Save alanerzhao/a51f6f61f7c5ee38ae82 to your computer and use it in GitHub Desktop.
//
(function (){
var telReg = /^0?(13|14|15|18)[0-9]{9}$/;
var regMail = /^\w+((-w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
var stepText = $(".step-text");
var mailBtn= $(".mail-btn");
var mobileBtn = $(".mobile-btn");
var newPass = $(".new-pass");
var repePass = $(".repe-pass");
var passBtn = $(".pass-btn");
//公用弹出层
var popuphit = {
mask: $('<div class="tips-wrap"><p class="tips-text">aaa</p></div>'),
init: function (config) {
var self = this;
this.popupObj = $(self.mask);
var that = this,
body = $(document.body);
this.popupObj.appendTo(body);
this.tipsText = $(".tips-text");
this.setMask();
this.show(config);
},
setMask: function () {
var winObj = $(window),
doc = $(document),
win = {
T: winObj.scrollTop(),
L: winObj.scrollLeft(),
H: winObj.height(),
W: winObj.width()
},
doc = {
H : doc.height(),
W : doc.width()
};
obj = {
H: this.popupObj.outerHeight(true),
W: this.popupObj.outerWidth(true),
L: this.popupObj.offset().left,
T: this.popupObj.offset().top
};
this.popupObj.css({
left: ((win.W - obj.W) / 2) + win.L,
top: ((win.H - obj.H) / 2) + win.T -100
});
},
show: function (config) {
var that = this;
that.tipsText.text(config)
that.popupObj.fadeIn();
setTimeout(function() {
that.hide();
},1000);
},
hide: function () {
this.popupObj.fadeOut();
this.mask.fadeOut()
}
}
//邮箱
mailBtn.click(function () {
if(regMail.test(stepText.val())) {
popuphit.init("ok")
} else {
popuphit.init("error")
}
})
//手机
mobileBtn.click(function () {
if(telReg.test(stepText.val())) {
popuphit.init("ok")
} else {
popuphit.init("error")
}
})
//重复密码
passBtn.click(function () {
var newVal = newPass.val();
var reVal = repePass.val();
if(newVal == reVal && (newVal && reVal)!="" ) {
popuphit.init("ok")
} else {
popuphit.init("error")
}
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment