']});
gtag('event', 'page_view', { 'send_to': [' '],
'ecomm_pagetype': 'login',
'ecomm_site': ymcart_site_type,
'source': ymcart_utm_source,
'medium': ymcart_utm_medium,
});
if(rs.ref)
{
window.location.href=rs.ref;
}
else
{
window.location.href="/h-account-index.html";
}
}else if(rs.msg){
$('#login_submit').tip(rs.msg, 15, 0, 2000);
}
},
beforeSend: function(){
createAjaxLoading();
},
complete: function(){
removeAjaxLoading();
}
});
return false;
});
$('#reg_email').click(function () {
// $(this).autoEmail();
});
$('#email').keypress(function () {
var pos = $(this).offset();
var emailObj = $(this);
if ($(this).val() != '') {
$('
').appendTo(document.body).addClass('input_clear_btn').attr('href', 'javascript:;').text('').css({
left: pos.left + $(this).innerWidth() - $(this).height(),
top: pos.top,
height: $(this).height(),
width: $(this).height(),
"line-height": $(this).height() + 'px'
}).fadeIn(200).click(function () {
emailObj.val('');
});
}
});
$('#reg_email').keypress(function () {
var pos = $(this).offset();
var emailObj = $(this);
if ($(this).val() != '') {
$('
').appendTo(document.body).addClass('input_clear_btn').attr('href', 'javascript:;').text('').css({
left: pos.left + $(this).innerWidth() - $(this).height(),
top: pos.top,
height: $(this).height(),
width: $(this).height(),
"line-height": $(this).height() + 'px'
}).fadeIn(200).click(function () {
emailObj.val('');
});
}
});
$('#validateImg').bind('click', function () {
$(this).attr('src', "/image.php?code=1&_=" + Math.random());
});
var is_submit = true;
$('#register_form').submit(function () {
if(!is_submit)
{
return false;
}
$('#reg_email').val($('#reg_email').val().replace(/(^\s*)|(\s*$)/g, ""));
if($('#reg_email').val()=='' || $('#user_name').val()=='Email Address') {
$('#reg_email').tip("Please enter the Email", 15, 0, 2000);
return false;
}
$isvalidemail=/^((([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($('#reg_email').val());
if(!$isvalidemail)
{
$('#reg_email').tip("The Email is invalid", 15, 0, 2000);
return false;
}else{
var flag = false;
$.ajax({
url: "/h-user-ExistEmail.html",
type: 'POST',
async : false,
data: {
email : $('#reg_email').val()
},
dataType: 'json',
cache: false,
beforeSend: function(){
createAjaxLoading();
},
complete: function(){
removeAjaxLoading();
},
success: function (res) {
if(!res.status){
$('#reg_email').tip("The Email is already existed, Please login directly", 15, 0, 2000);
flag = true;
}
}
});
if(flag){
return false;
}
}
if($('#password').val()=='' || $('#password').val()=='Password (6-30 characters)')
{
$('#password').tip("Please enter the password", 15, 0, 2000);
return false;
}
//_ps =/^[a-zA-Z0-9]{6,20}$/.test($('#password').val());
if(!/^.{6,20}$/.test($('#password').val()))
{
$('#password').tip("The password's length should be between 6-20", 15, 0, 2000);
return false;
}
if($('#confirm_password').val()!= $('#password').val())
{
$('#confirm_password').tip("Please enter the same two passwords", 15, 0, 2000);
return false;
}
var code = $("input[name='validateCode']");
if (!code.val())
{
code.tip("Please enter the correct verification code", 15, 0, 2000);
return false;
}
ymcart_user_email = $('#reg_email').val();
$.ajax({
url: $('#register_form').attr('action'),
type: 'POST',
async : false,
data: $('#register_form').serialize(),
dataType: 'json',
cache: false,
beforeSend: function(){
is_submit = false;
createAjaxLoading();
},
complete: function(){
removeAjaxLoading();
is_submit = true;
},
success: function (res) {
if(res.status){
// Ymcart Event[CompleteRegistration]
if(typeof(ytag)=='function'){
ytag("sign_up","",0,0,0,'');
}
// Global Site Tag (gtag.js) - Google Analytics[sign_up]
gtag('event', 'sign_up', {'send_to':[' ']});
gtag('event', 'page_view', { 'send_to': [' '],
'ecomm_pagetype': 'sign_up',
'ecomm_site': ymcart_site_type,
'source': ymcart_utm_source,
'medium': ymcart_utm_medium,
});
// Ymcart Event[Login]
if(typeof(ytag)=='function'){
ytag("login","",0,0,0,'');
}
// Global Site Tag (gtag.js) - Google Analytics[login]
gtag('event', 'login', {'send_to':[' ']});
gtag('event', 'page_view', { 'send_to': [' '],
'ecomm_pagetype': 'login',
'ecomm_site': ymcart_site_type,
'source': ymcart_utm_source,
'medium': ymcart_utm_medium,
});
$('#register_submit').tip(res.msg, 15, 0, 2000);
if(typeof res.ref != "undefined")
{
location.href = res.ref;
}
else
{
location.href = "h-account-index.html";
}
}
else
{
$('#register_submit').tip(res.msg, 15, 0, 2000);
}
}
});
return false;
});
});
$('#validateImg').attr('src', "/image.php?code=1&_=" + Math.random());