You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.7 KiB
JavaScript

//zodiac coupon
function submition()
{
var obj_user = $('input[name="username"]');
var obj_email = $('input[name="useremail"]')
var username = obj_user.val();
var useremail = obj_email.val();
var errnum = 0;
if(username == '')
{
obj_user.attr('placeholder','Please fill in your name');
obj_user.addClass('warning')
//console.log('Invalid Name');
errnum += 1;
}
if(!checkEamil(useremail))
{
obj_email.addClass('warning');
obj_email.attr('placeholder','Please fill in a valid email address');
//console.log('Invalid Email');
errnum += 1;
}
if(errnum == 0)
{
$.ajax({
url:'/forms/save-coupon.asp',
type:'POST',
data:$('#coupon').serialize(),
success: function(str){
if(str=='ok')
{
window.location.href='/forms/thankyou-zodiac.asp';
}else if(str == 'emailexists'){
$("#errmail").remove();
var tmp = '<div id="errmail" style="color:#a31022">The e-mail already exists</div>';
$('#coupon').append(tmp);
}else{
alert(str);
//console.log(str);
}
}
});
}
}
function checkEamil(o) {
if ( !( /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(o))) {
return false;
} else {
return true;
}
}
document.writeln(" <div id=\"zodiacPromo\">");
document.writeln(" <form id=\"coupon\">");
document.writeln(" <label>Name: </label>");
document.writeln(" <input type=\"text\" name=\"username\" id=\"username\">");
document.writeln(" <div class=\"clear\"></div>");
document.writeln(" <label>Email: </label>");
document.writeln(" <input type=\"text\" name=\"useremail\" id=\"useremail\" >");
document.writeln(" </form>");
document.writeln(" <a class=\"luckyButton\" href=\"javascript:;\" onClick=\"submition()\"><img src=\"/pic/i-am-lucky.png\"></a>");
document.writeln(" <a class=\"fbFollow\" href=\"http://www.facebook.com/Chinahighlights\"><img src=\"/pic/fb-93x16.png\"></a>");
document.writeln(" </div>");