jQuery(document).ready(function(){
//jQuery("#phoneNumber").mask("?(999) 999-9999");
//jQuery("#accountZip, #billingZip").mask("99999");
//jQuery("#ccNumber").mask("?9999999999999999");
jQuery("#y_monthlyprice_default").val(jQuery("#y_monthlyprice").text());
jQuery("#y_saving_default").val(jQuery("#y_saving").text());
//Signup account page
var emailIdInput = jQuery("#emailId");
var passwordInput = jQuery("#password");
var passwordConfirmInput = jQuery("#passwordConfirm");
var companyNameInput = jQuery("#companyName");
var signupTitleInput = jQuery("#signupTitle");
var firstNameInput = jQuery("#firstName");
var lastNameInput = jQuery("#lastName");
var accountAddressInput = jQuery("#accountAddress");
var accountCityInput = jQuery("#accountCity");
var accountStateInput = jQuery("#accountState");
var accountZipInput = jQuery("#accountZip");
var phoneNumberInput = jQuery("#phoneNumber");
var signupHearInputInput = jQuery("#signupHearInput");
var ccNumberInput =jQuery("#ccNumber");
var ccExpMonthInput = jQuery("#ccExpMonth");
var ccExpYearInput = jQuery("#ccExpYear");
var ccSecCodeInput = jQuery("#ccSecCode");
var billingCityInput = jQuery("#billingCity");
var nameOnCardInput = jQuery("#billingName");
var billingAddressInput = jQuery("#billingAddress");
var billingZipInput = jQuery("#billingZip");
var submitSignupAccountInfoButton = jQuery("#submitSignupAccountInfo");
var resetSignupAccountInfoButton = jQuery("#resetSignupAccountInfo");
var signUpPromoCodeButton = jQuery("#applyPromoCode");
var submitSignupBillingInfoButton = jQuery("#submitSignupBillingInfo");
var submitSignupBillingInfoButtonOldCC = jQuery("#submitSignupBillingInfoOldCC");
var tncInput = jQuery('#tnc');
var tnc2Input = jQuery('#tnc2');
//Login Page
var loginUsernameInput = jQuery("#username");
var loginPasswordInput = jQuery("#password");
var loginButton = jQuery("#login_submit");
var loginReset = jQuery("#login_reset");
if(jQuery("#authenticatedUserName").val() != ""){
jQuery("#emailId").val(jQuery("#authenticatedUserName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#password").val("123456").prop("type", "password").css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#passwordConfirm").val("123456").prop("type", "password").css("border-color", "#CECECE").attr("disabled", "disabled");
//jQuery("#companyName").val(jQuery("#authenticatedCompanyName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#firstName").val(jQuery("#authenticatedFirstName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#lastName").val(jQuery("#authenticatedLastName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountAddress").val(jQuery("#authenticatedAddress").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountCity").val(jQuery("#authenticatedCity").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountState").val(jQuery("#authenticatedState").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountZip").val(jQuery("#authenticatedZip").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#phoneNumber").val(jQuery("#authenticatedPhone").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
}else{
jQuery("#emailId").val("").removeAttr("disabled");
jQuery("#password").val("").removeAttr("disabled");
jQuery("#passwordConfirm").val("").removeAttr("disabled");
//jQuery("#companyName").val("").removeAttr("disabled");
jQuery("#firstName").val("").removeAttr("disabled");
jQuery("#lastName").val("").removeAttr("disabled");
jQuery("#accountAddress").val("").removeAttr("disabled");
jQuery("#accountCity").val("").removeAttr("disabled");
jQuery("#accountState").val("").removeAttr("disabled");
jQuery("#accountZip").val("").removeAttr("disabled");
jQuery("#phoneNumber").val("").removeAttr("disabled");
}
// error information icon display
var error_img = '';
// step by step sign up trigger
var stepByStep = false;
function showErrorInfo(field, error_icon, error_text) {
if( field.parent().parent().find(".error_icon").length < 1) {
field.parent().parent().append(error_icon);
}
field.addClass("validate_error");
field.css("border-color", "#D31F45");
field.attr("title", error_text);
findNextError()
}
function findNextError() {
var nextError = $('.validate_error').first();
if(nextError != null) {
jQuery(".permanent").remove();
var tip = nextError.tooltip({
position: {
my: "center bottom-30",
at: "left center",
using: function( position, feedback ) {
$( this ).css( position );
$( "
" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
tip.tooltip("open");
var permanent = jQuery(".ui-tooltip").clone();
permanent.addClass("permanent");
permanent.css("opacity", 1);
jQuery("body").append(permanent);
tip.tooltip("destroy");
}
}
function removeErrorInfo(field) {
field.css("border-color", "#CECECE");
field.tooltip();
field.tooltip("destroy");
field.removeClass("validate_error");
field.attr("title","");
var error_number = field.parent().parent().find(".validate_error").length;
if(error_number < 1) {
field.parent().parent().find(".error_icon").remove();
}
findNextError();
}
emailIdInput.focus(function(){
emailIdInput.keyup(function(e) {
var email = emailIdInput.val();
email = email.replace(/\s+/g, '');
emailIdInput.val(email);
});
emailIdInput.change(function(e) {
var email = emailIdInput.val();
email = email.replace(/\s+/g, '');
emailIdInput.val(email);
});
});
ccNumberInput.focus(function(){
ccNumberInput.keyup(function(e) {
var cardNumber = ccNumberInput.val().replace(/_/g,"");
predictCreditCardCompany(cardNumber);
});
ccNumberInput.mouseup(function(e) {
var cardNumber = ccNumberInput.val().replace(/_/g,"");
predictCreditCardCompany(cardNumber);
});
});
emailIdInput.blur(function(){
if(emailIdInput.val() != '') {
validateAJAXEmail(false);
validateAll();
} else {
removeErrorInfo(emailIdInput);
}
});
passwordInput.blur(function(){
if(passwordInput.val() != '') {
validatepassword(passwordInput);
validateAll();
} else {
removeErrorInfo(passwordInput);
}
});
passwordConfirmInput.blur(function(){
if(passwordConfirmInput.val() != '') {
validatepasswordconfirm(passwordInput,passwordConfirmInput);
validateAll();
} else {
removeErrorInfo(passwordConfirmInput);
}
});
firstNameInput.blur(function(){
if(firstNameInput.val() != '') {
validateFirstName();
validateAll();
} else {
removeErrorInfo(firstNameInput);
}
});
lastNameInput.blur(function(){
if(lastNameInput.val() != '') {
validateLastName();
validateAll();
} else {
removeErrorInfo(lastNameInput);
}
});
accountAddressInput.blur(function(){
if(accountAddressInput.val() != '') {
validateAddress();
validateAll();
} else {
removeErrorInfo(accountAddressInput);
}
});
nameOnCardInput.blur(function(){
if(nameOnCardInput.val() != '') {
validateNameOnCard();
validateAll();
} else {
removeErrorInfo(nameOnCardInput);
}
});
accountCityInput.blur(function(){
if(accountCityInput.val() != '') {
validateCity();
validateAll();
} else {
removeErrorInfo(accountCityInput);
}
});
billingCityInput.blur(function(){
if(billingCityInput.val() != '') {
validateBillingCity();
validateAll();
} else {
removeErrorInfo(billingCityInput);
}
});
accountZipInput.blur(function(){
if(accountZipInput.val() != '') {
validateZip();
validateAll();
} else {
removeErrorInfo(accountZipInput);
}
});
phoneNumberInput.blur(function(){
if(phoneNumberInput.val() != '') {
validatePhoneNumber();
validateAll();
} else {
removeErrorInfo(phoneNumberInput);
}
});
ccNumberInput.blur(function(){
if(ccNumberInput.val() != '') {
validateCard();
validateAll();
} else {
removeErrorInfo(ccNumberInput);
}
});
ccSecCodeInput.blur(function(){
if(ccSecCodeInput.val() != '') {
validateCVV();
validateAll();
} else {
removeErrorInfo(ccSecCodeInput);
}
});
billingAddressInput.blur(function(){
if(billingAddressInput.val() != '') {
validateBillingAddress();
validateAll();
} else {
removeErrorInfo(billingAddressInput);
}
});
billingZipInput.blur(function(){
if(billingZipInput.val() != '') {
validateccZip();
validateAll();
} else {
removeErrorInfo(billingZipInput);
}
});
jQuery("#signupHearInput").blur(validateReferral);
// jQuery("#termsConditions").blur(validateTermCondition);
function validateAll(){
if(!stepByStep) {
return;
}
jQuery(".error_icon").remove();
if(jQuery("#isFreeTrialHidden").val() == "false"){
if(
validateEmail() &
validatepassword(passwordInput) &
validatepasswordconfirm(passwordInput,passwordConfirmInput) &
validateFirstName() &
validateLastName() &
validatePhoneNumber() &
validateCompanyName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validateReferral() & validateTNC() & validateTNC2()
) {
return true;
} else {
return false;
}
} else {
if(jQuery("#sameAddress").is(':checked')) {
if(
validateEmail() &
validatepassword(passwordInput) &
validatepasswordconfirm(passwordInput,passwordConfirmInput) &
validateCompanyName() &
validateFirstName() &
validateLastName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validatePhoneNumber() &
validateCard() &
validateCVV() &
validateReferral() & validateTNC() & validateTNC2()
) {
return true;
} else {
return false;
}
} else {
if(
validateEmail() &
validatepassword(passwordInput) &
validatepasswordconfirm(passwordInput,passwordConfirmInput) &
validateCompanyName() &
validateFirstName() &
validateLastName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validatePhoneNumber() &
validateCard() &
validateCVV() &
validateReferral() & validateTNC() & validateTNC2()
) {
return true;
} else {
return false;
}
}
}
}
submitSignupAccountInfoButton.click(function(){
validateAJAXEmail(true);
});
submitSignupBillingInfoButton.click(function(){
$(this).attr("disabled", "disabled");
submitBillingForm();
});
submitSignupBillingInfoButtonOldCC.click(function(){
if ($('input[name=useExisting]:checked').length > 0) {
$(this).attr("disabled", "disabled");
submitBillingFormOldCC();
}else{
$('#cardError2').text('Please Select Payment Option.');
}
});
$('#addCCButton').on("click", (event) => {
submitAddCreditCardForm();
});
jQuery("#rememberMe").attr('checked', false);
loginButton.click(function(){
if(
validateLoginUsername()
){
if (jQuery("#rememberMe").attr('checked') == "checked") {
jQuery("#rememberMeCheckbox").val("checked");
} else {
jQuery("#rememberMeCheckbox").val("unchecked");
}
jQuery("#loginInformation").submit();
return true;
}else{
return false;
}
});
jQuery(document).keyup(function(e){
if (e.which == 13){
if (jQuery("#login_submit").text() == "Login") {
if (validateLoginUsername()) {
jQuery("form#loginInformation").submit();
return true;
} else {
return false;
}
} else {
return false;
}
}
});
loginReset.click(function(){
loginUsernameInput.val("");
loginPasswordInput.val("");
jQuery("#loginStatus, #loginError").css("display", "none");
});
loginUsernameInput.focusout(function(){
var loginEmail = loginUsernameInput.val();
jQuery("#username").val(jQuery.trim(loginEmail));
});
function validateLoginUsername(){
var loginEmail = loginUsernameInput.val();
var filter = /^((([a-zA-Z]|\d|[!#$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-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-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;
if(filter.test(loginEmail)){
jQuery("#loginError").css("display", "none");
return validateLoginPassword();
}else{
jQuery("#loginError").text("The Email entered is not valid.").css("display", "block");
return false;
}
};
function validateLoginPassword(){
var loginPassword = loginPasswordInput.val();
var filter = /^[0-9a-zA-Z!@"%&'()*\+,\/;\[\\\]\^_`{|}~#$\-=:<>?]{5,15}$/;
if(filter.test(loginPassword)){
jQuery("#loginError").css("display", "none");
return true;
}else{
jQuery("#loginError").text("Invalid password!").css("display", "block");
return false;
}
};
function submitBillingForm() {
if (
validatePackage() &
validateCard() &
validateCVV() &
validateNameOnCard() &
validateBillingCity() & validateTNC() & validateTNC2()
) {
var dia = {
modal: true,
width : 650,
resizable: false
}
signingUp = true;
jQuery('#submitBillingInfoLoading').dialog(dia).dialog("open");
jQuery('#signupBillingInfomration').submit();
return true;
} else {
$('#submitSignupBillingInfo').removeAttr("disabled");
return false;
}
}
function submitAddCreditCardForm() {
$("#renewSubscriptionButton").attr("disabled", "disabled");
if (
validateCard() &
validateCVV() &
validateBillingAddress() &
validateccZip()) {
$('#addCardModal').modal('hide');
$('#submitCardLoading').dialog(dia).dialog("open");
$('#addCreditCard').submit();
$('#addCreditCard').trigger("reset");
return true;
} else {
$('#renewSubscriptionButton').removeAttr("disabled");
return false;
}
}
function submitBillingFormOldCC() {
var dia = {
modal: true,
width : 650,
resizable: false
}
signingUp = true;
jQuery('#submitBillingInfoLoading').dialog(dia).dialog("open");
jQuery('#signupBillingInfomration').submit();
return true;
}
function submitSignupForm() {
stepByStep = true;
signingUp = true;
jQuery(".error_icon").remove();
if(jQuery("#autoPass").val()){
if(
validateEmail() &
validateFirstName() &
validateLastName() &
validatePhoneNumber() &
validateCompanyName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validateReferral() & validateTNC() & validateTNC2()
) {
jQuery('#signupAccountInfomration').submit();
return true;
} else {
return false;
}
} else if(jQuery("#isFreeTrialHidden").val() == "false"){
if(
validateEmail() &
validatepassword(passwordInput) &
validateFirstName() &
validateLastName() &
validatePhoneNumber() &
validateCompanyName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validateReferral() & validateTNC() & validateTNC2()
) {
jQuery('#signupAccountInfomration').submit();
return true;
} else {
return false;
}
} else {
if(jQuery("#sameAddress").is(':checked')) {
if(
validateEmail() &
validatepassword(passwordInput) &
validatepasswordconfirm(passwordInput,passwordConfirmInput) &
validateCompanyName() &
validateFirstName() &
validateLastName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validatePhoneNumber() &
validateCard() &
validateCVV() &
validateReferral() & validateTNC() & validateTNC2()
) {
if(billingPlanType == "W"){
jQuery("#afterDiscountPrice").val(jQuery("#weekTrailAfterDiscountPrice").val());
}else{
}
var dia = {
modal: true,
width : 650,
resizable: false
}
jQuery('#submitAccountInfoLoading').dialog(dia).dialog("open");
jQuery('#signupAccountInfomration').submit();
return true;
} else {
return false;
}
} else {
var isFSL= $("#isFSL").val();
var passwordConfirmInput = (isFSL == "true")? jQuery("#password"): jQuery("#passwordConfirm");
if(
validateEmail() &
validatepassword(passwordInput) &
validatepasswordconfirm(passwordInput,passwordConfirmInput) &
validateCompanyName() &
validateFirstName() &
validateLastName() &
validateAddress() &
validateCity() &
validateState() &
validateZip() &
validatePhoneNumber() &
validateReferral() & validateTNC() & validateTNC2()
) {
if(billingPlanType == "W"){
jQuery("#afterDiscountPrice").val(jQuery("#weekTrailAfterDiscountPrice").val());
}else{
}
var dia = {
modal: true,
width : 650,
resizable: false
}
jQuery('#submitAccountInfoLoading').dialog(dia).dialog("open");
jQuery('#signupAccountInfomration').submit();
return true;
} else {
return false;
}
}
}
}
resetSignupAccountInfoButton.click(function(){
stepByStep = false;
jQuery(".error_icon").remove();
jQuery(".permanent").remove();
jQuery(".validate_error").removeClass("validate_error");
jQuery("#accountError").val("");
jQuery("#cardError").val("");
jQuery("#weekTrialPromoResult").text("");
jQuery("#emailId, #password, #passwordConfirm, #firstName, #lastName, #accountAddress, #accountCity, #accountState, #accountZip, #phoneNumber, #signupHearInput, #ccNumber, #ccSecCode, #billingName, #billingAddress, #billingCity, #billingZip").css("border-color", "#CECECE");
jQuery(".bottomLeftCoverClass input").each(function(){
jQuery(this).prev('span').css({'visibility': '', 'color': '#999999'});
});
jQuery(".bottomRightContentClass input").each(function(){
jQuery(this).prev('span').css({'visibility': '', 'color': '#999999'});
});
jQuery(".twoPageBottomLeftCoverClass_shrink input").each(function(){
jQuery(this).prev('span').css({'visibility': '', 'color': '#999999'});
});
jQuery(".twoPageBottomRightContentClass_shrink input").each(function(){
jQuery(this).prev('span').css({'visibility': '', 'color': '#999999'});
});
jQuery("#masterCard, #visaCard, #amExCard, #discoverCard").animate({ opacity: 1}, 1);
jQuery("#billingZip").val("").prop('disabled', false);
});
function validateEmail(){
var emailId = emailIdInput.val();
var filter = /^((([a-zA-Z]|\d|[!#$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-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-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;
if(filter.test(emailId)){
removeErrorInfo(jQuery("#emailId"));
return true;
}
else{
showErrorInfo( jQuery("#emailId"), error_img, "Doesn't look like a valid email");
return false;
}
};
function validateFirstName(){
var filter = /([a-zA-Z]{2,20}\s*)+/;
var firstName = firstNameInput.val();
var firstNameLength = firstName.length;
if(firstName == null || firstName == 'null' || firstName == "null"){
showErrorInfo( firstNameInput, error_img, "A valid name contains at least 2 letters.");
return false;
} else if(filter.test(firstName)){
removeErrorInfo(firstNameInput);
return true;
} else if(firstNameLength < 2){
showErrorInfo( firstNameInput, error_img, "A valid name contains at least 2 letters.");
return false;
}
else{
showErrorInfo( firstNameInput, error_img, "A valid name contains at least 2 letters.");
return false;
}
};
function validateLastName(){
var filter = /([a-zA-Z]{2,20}\s*)+/;
var lastName = lastNameInput.val();
var lastNameLength = lastName.length;
if(lastName == null || lastName == 'null' || lastName == "null"){
showErrorInfo( lastNameInput, error_img, "A valid name contains at least 2 letters.");
return false;
} else if(filter.test(lastName)){
removeErrorInfo(lastNameInput);
return true;
} else if(lastNameLength < 2){
showErrorInfo( lastNameInput, error_img, "A valid name contains at least 2 letters.");
return false;
} else{
showErrorInfo( lastNameInput, error_img, "A valid name contains at least 2 letters.");
return false;
}
};
function validatePhoneNumber(){
var phoneNumber = phoneNumberInput.val();
var filter = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
if(filter.test(phoneNumber)){
removeErrorInfo(phoneNumberInput);
return true;
}
else{
showErrorInfo( phoneNumberInput, error_img, "We need a valid phone number");
return false;
}
};
function validateCompanyName(){
return true;
};
function validateAddress(){
var address = accountAddressInput.val();
var filter = /^(?!\s*$).+/;
if(filter.test(address)){
removeErrorInfo(accountAddressInput);
return true;
}
else{
showErrorInfo( accountAddressInput, error_img, "A valid address contains at least 2 characters.");
return false;
}
};
function validateNameOnCard(){
var name = nameOnCardInput.val();
var filter = /^(?!\s*$).+/;
if(filter.test(name)){
removeErrorInfo(nameOnCardInput);
return true;
}
else{
showErrorInfo( nameOnCardInput, error_img, "Enter your name as it appears on the card");
return false;
}
};
function validateCity(){
var city = accountCityInput.val();
var filter = /^(?!\s*$).+/;
if(filter.test(city)){
removeErrorInfo(accountCityInput);
return true;
}
else{
showErrorInfo( accountCityInput, error_img, "A valid city name contains at least 2 characters.");
return false;
}
};
function validateBillingCity(){
var city = billingCityInput.val();
var filter = /^(?!\s*$).+/;
if(filter.test(city)){
removeErrorInfo(billingCityInput);
return true;
}
else{
showErrorInfo( billingCityInput, error_img, "A valid city name contains at least 2 characters.");
return false;
}
};
function validateState(){
var state = accountStateInput.val();
if(state == "State" ){
showErrorInfo( accountStateInput, error_img, "We need a valid state");
return false;
}else{
removeErrorInfo(accountStateInput);
return true;
}
};
function validateZip(){
var zip = accountZipInput.val();
var filter = /^\(?(\d{5})\)?$/;
if(filter.test(zip)){
removeErrorInfo(accountZipInput);
return true;
}
else{
showErrorInfo( accountZipInput, error_img, "A valid ZIP code contains 5 digits");
return false;
}
};
function validateHearInput(){
return true;
};
function validateBillingAddress(){
var billingAddress = billingAddressInput.val();
var filter = /^(?!\s*$).+/;
if(filter.test(billingAddress)){
removeErrorInfo(billingAddressInput);
return true;
}
else{
showErrorInfo( billingAddressInput, error_img, "A valid address contains at least 2 characters.");
return false;
}
};
function validateccZip(){
var ccZip = billingZipInput.val();
var filter = /^\(?(\d{5})\)?$/;
if(filter.test(ccZip)){
removeErrorInfo(billingZipInput);
return true;
}
else{
showErrorInfo( billingZipInput, error_img, "A valid ZIP code contains 5 digits");
return false;
}
};
function validateAJAXEmail(submitForm){
jQuery("#emailId").parent().parent().find(".error_icon").remove();
var emailId = jQuery("#emailId").val();
if(jQuery("#authenticatedUserName").val() == emailId && emailId != ""){
jQuery("#emailId").val(jQuery("#authenticatedUserName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#password").val("123456").prop("type", "password").css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#passwordConfirm").val("123456").prop("type", "password").css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#firstName").val(jQuery("#authenticatedFirstName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#lastName").val(jQuery("#authenticatedLastName").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountAddress").val(jQuery("#authenticatedAddress").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountCity").val(jQuery("#authenticatedCity").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountState").val(jQuery("#authenticatedState").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#accountZip").val(jQuery("#authenticatedZip").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
jQuery("#phoneNumber").val(jQuery("#authenticatedPhone").val()).css("border-color", "#CECECE").attr("disabled", "disabled");
submitSignupForm();
}else{
var filter = /^((([a-zA-Z]|\d|[!#$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-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-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;
if(filter.test(emailId)){
if(submitForm == true) {
submitSignupForm();
}
return true;
var obj = {"user_name":emailId, "action":"getUserName"};
var endPoint = "./emailcheck";
var error_img = '
';
var ajax_load_img = '
';
jQuery.ajax(endPoint, {'type': 'GET', 'data': obj,
'beforeSend': function(jqXHR, settings){
if( jQuery("#emailId").parent().parent().find(".ajax_load_img").length < 1) {
jQuery("#emailId").parent().parent().append(ajax_load_img);
}
},
'complete': function(jqXHR, textStatus){
jQuery(".ajax_load_img").remove();
if(jqXHR.status == 200 && jqXHR.responseText == ''){
removeErrorInfo(jQuery("#emailId"));
if(submitForm == true) {
submitSignupForm();
}
return true;
}else{
if (jqXHR.responseText.indexOf("@") !== -1) {
showErrorInfo( jQuery("#emailId"), error_img, "Username taken, login or use different email. Click
here to login.");
} else {
showErrorInfo( jQuery("#emailId"), error_img, "This email service provider ( " + jqXHR.responseText + ") is not permitted.");
}
return false;
}
}});
}
else{
showErrorInfo( jQuery("#emailId"), error_img, "You forgot to enter your email");
return false;
}
}
};
function validateCard(){
var creditCardNumber = ccNumberInput.val();
var filter = /^\d+$/;
var goodCard = false;
if(filter.test(creditCardNumber)){
goodCard = findCreditCardCompany(creditCardNumber);
if(goodCard) {
removeErrorInfo(ccNumberInput);
} else {
showErrorInfo( ccNumberInput, error_img, "That credit card doesn't look valid!");
jQuery("#masterCard, #visaCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
}
return goodCard;
}
showErrorInfo( ccNumberInput, error_img, "That credit card doesn't look valid!");
return goodCard;
};
function validatePackage() {
var pValue = jQuery("#selectedPackage").val();
var retval = false;
if(pValue != undefined && pValue != "" && pValue != null) {
var ipv = parseInt(pValue);
retval = !isNaN(pValue) && (ipv | 0) === ipv;
}else{
jQuery("#error-plan").text("Please select a plan.");
$('#submitSignupBillingInfo').removeAttr("disabled");
}
return retval;
}
function validateExpDate() {
var month = jQuery("#ccExpMonth").val() - 1;
var year = jQuery("#ccExpYear").val()
var expDate = new Date( year, month );
var curDate = new Date();
if(expDate < curDate) {
showErrorInfo( jQuery("#ccExpYear"), error_img, "This Credit Card is expired.");
showErrorInfo( jQuery("#ccExpMonth"), error_img, "This Credit Card is expired.");
} else {
removeErrorInfo(jQuery("#ccExpYear"));
removeErrorInfo(jQuery("#ccExpMonth"));
}
return expDate > curDate;
}
function validateCardExpDate(){
var expMonth = ccExpMonthInput.val();
var expYear = ccExpYearInput.val();
if(expMonth == "Month" || expYear == "Year"){
showErrorInfo( ccExpMonthInput, error_img, "Please enter the expiration date");
return false;
}else{
removeErrorInfo(ccExpMonthInput);
return true;
}
};
function validateCVV(){
var cardCVV = ccSecCodeInput.val();
cardCVV = cardCVV.replace(/_/g,"");
var filter = /^\(?(\d{3,4})\)?$/;
if(cardCVV != '') {
if(filter.test(cardCVV)){
removeErrorInfo(ccSecCodeInput);
return true;
}else{
showErrorInfo( ccSecCodeInput, error_img, "The security code doesn't look valid!");
return false;
}
}
showErrorInfo( ccSecCodeInput, error_img, "The security code doesn't look valid!");
return false;
};
function predictCreditCardCompany(creditCardNumber) {
var masterCardRegEx = /^5[1-5]/;
var visaCardRegEx = /^4/;
var amExpCardRegEx = /^3[4-7]/;
var discoverCardRegEx = /^6(?:011|5[0-9]{2})/;
if (masterCardRegEx.test(creditCardNumber)) {
jQuery("#masterCard").animate({ opacity: 1}, 1);
jQuery("#visaCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("999");
jQuery("#enteredCreditCardType").val("Master");
return true;
} else if(visaCardRegEx.test(creditCardNumber)){
jQuery("#visaCard").animate({ opacity: 1}, 1);
jQuery("#masterCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("999");
jQuery("#enteredCreditCardType").val("Visa");
return true;
} else if(amExpCardRegEx.test(creditCardNumber)){
jQuery("#amExCard").animate({ opacity: 1}, 1);
jQuery("#masterCard, #visaCard, #discoverCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("9999");
jQuery("#enteredCreditCardType").val("American Express");
return true;
} else if(discoverCardRegEx.test(creditCardNumber)){
jQuery("#discoverCard").animate({ opacity: 1}, 1);
jQuery("#masterCard, #visaCard, #amExCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("999");
jQuery("#enteredCreditCardType").val("Discover");
return true;
} else{
jQuery("#masterCard, #visaCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
return false;
}
}
function findCreditCardCompany(creditCardNumber){
var masterCardRegEx = /^5[1-5][0-9]{14}$/;
var visaCardRegEx = /^4[0-9]{12}(?:[0-9]{3})?$/;
var amExpCardRegEx = /^3[4-7][0-9]{13}$/;
var discoverCardRegEx = /^6(?:011|5[0-9]{2})[0-9]{12}$/;
if (masterCardRegEx.test(creditCardNumber)) {
jQuery("#masterCard").animate({ opacity: 1}, 1);
jQuery("#visaCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("999");
jQuery("#enteredCreditCardType").val("Master");
return true;
} else if(visaCardRegEx.test(creditCardNumber)){
jQuery("#visaCard").animate({ opacity: 1}, 1);
jQuery("#masterCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("999");
jQuery("#enteredCreditCardType").val("Visa");
return true;
} else if(amExpCardRegEx.test(creditCardNumber)){
jQuery("#amExCard").animate({ opacity: 1}, 1);
jQuery("#masterCard, #visaCard, #discoverCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("9999");
jQuery("#enteredCreditCardType").val("American Express");
return true;
} else if(discoverCardRegEx.test(creditCardNumber)){
jQuery("#discoverCard").animate({ opacity: 1}, 1);
jQuery("#masterCard, #visaCard, #amExCard").animate({ opacity: 0.25}, 1);
//jQuery("#ccSecCode").mask("999");
jQuery("#enteredCreditCardType").val("Discover");
return true;
} else{
jQuery("#masterCard, #visaCard, #amExCard, #discoverCard").animate({ opacity: 0.25}, 1);
return false;
}
};
function validateReferral() {
var referral = jQuery("#signupHearInput").val();
if(referral != "undefined"){
removeErrorInfo(jQuery("#signupHearInput"));
return true;
} else {
showErrorInfo( jQuery("#signupHearInput"), "", "Please select how you heard about us?");
return false;
}
}
jQuery("#tnc").click(function() {removeErrorInfo(jQuery("#tnc"));} );
function validateTNC() {
if (jQuery('#tnc').attr("type") != 'checkbox' || jQuery('#tnc').is(":checked") ) {
removeErrorInfo(jQuery("#tnc"));
return true;
} else {
showErrorInfo( jQuery("#tnc"), "", "Please accept the terms and conditions.");
return false;
}
}
jQuery("#tnc2").click(function() {removeErrorInfo(jQuery("#tnc2"));} );
function validateTNC2() {
if (jQuery('#tnc2').attr("type") != 'checkbox' || jQuery('#tnc2').is(":checked") ) {
removeErrorInfo(jQuery("#tnc2"));
return true;
} else {
showErrorInfo( jQuery("#tnc2"), "", "Please accept the terms and conditions.");
return false;
}
}
function toggleLabel(){
var input = jQuery(this);
setTimeout(function(){
var def = input.attr('title');
if(!input.val() || (input.val() == def)){
input.prev('span').css('visibility', '');
if(def){
var dummy = jQuery('
').text(def).css('visibility','hidden').appendTo('body');
input.prev('span').css('margin-left', 3 + 'px');
dummy.remove();
}
}else{
input.prev('span').css('visibility', 'hidden');
}
}, 0);
};
function resetField() {
var def = jQuery(this).attr('title');
if (!jQuery(this).val() || (jQuery(this).val() == def)) {
jQuery(this).val(def);
jQuery(this).prev('span').css('visibility', '');
}
};
jQuery('input, textarea').live('keydown', toggleLabel);
jQuery('input, textarea').live('paste', toggleLabel);
jQuery('select').live('change', toggleLabel);
jQuery('input, textarea').live('focusin', function() {
jQuery(this).prev('span').css('color', '#ccc');
jQuery(this).css({
'border-width': '1px',
'border-color': '#FF9C03'
});
if(jQuery(this).attr('id') == 'password' || jQuery(this).attr('id') == 'passwordConfirm'){
}
});
jQuery('input, textarea').live('focusout', function() {
if(jQuery(this).val() == '') {
removeErrorInfo(jQuery(this));
}
jQuery(this).prev('span').css({'color':'#999'});
jQuery(this).css({
'border-width':'1px',
'border-color': '#CECECE'
});
});
jQuery(function() {
jQuery('input, textarea').each(function() { toggleLabel.call(this); });
});
//var billingPlan = null;
var discountPrice = 0;
//billingPlan = jQuery(".packageSelector:checked").val();
var billingPlan = jQuery('input:radio[name=selectedPackage]:checked').val();
var billingPlanType = jQuery('input:radio[name=selectedPackage]:checked').attr('accessKey');
jQuery("#afterDiscountPrice").val("");
jQuery("#userSelectedBillingPlan").val(jQuery("#selectedPackage").val());
if(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text() != ""){
jQuery("#afterDiscountPrice").val(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text());
}else if(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text() != ""){
jQuery("#afterDiscountPrice").val(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text());
}
jQuery("#selectedPackage.packageSelector").click(function(){
billingPlan = jQuery('input:radio[name=selectedPackage]:checked').val();
if(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text() != ""){
jQuery("#afterDiscountPrice").val(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text());
}else if(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text() != ""){
jQuery("#afterDiscountPrice").val(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text());
}
jQuery("#userSelectedBillingPlan").val(jQuery('#selectedPackage').val());
promoCodeFirst = jQuery("#signupPromoCode").val();
if(promoCodeFirst != '' && promoCodeFirst.toString().length > 0 && promoCodeFirst != undefined){
getDiscountPrice();
}else{
}
});
signUpPromoCodeButton.click(function(){
getDiscountPrice();
});
jQuery("#applyPromoCodeImage").css("display","inline");
function getDiscountPrice(){
var promoCode = null;
promoCode = jQuery("#signupPromoCode").val();
if (promoCode == undefined) {
promoCode = jQuery("#userPromoCode").val();
}
obj = { "promocode":"none"};
if (promoCode != undefined) {
if (promoCode.toString().length > 0) {
var obj = { "promoCode": promoCode, "billingPlan" : billingPlan };
var endpoint = "./getPromoCode";
jQuery.ajax(endpoint, {
'type': "GET",
'data': obj,
'beforeSend': function(jqXHR, settings){
jQuery("#signupPromoCode").addClass('ui-autocomplete-loading');
},
'complete': function(jqXHR, data){
jQuery("#signupPromoCode").removeClass('ui-autocomplete-loading');
displayPromoDiscount(jqXHR, data);
}
});
return true;
}
return false;
}
return false;
};
function displayPromoDiscount(jqXHR, data){
jQuery("#afterDiscountPrice").val("");
if (jqXHR.status == 200) {
var dataj = jQuery.parseJSON(jqXHR.responseText);
if (dataj != null) {
if (dataj.value == "expiredPromoCode" || dataj.value == "invalid") {
if(billingPlanType == "W"){
jQuery("#weekTrialPromoResult").css("display","none");
}else{
jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text("");
jQuery("#"+billingPlan+".package span#billingDefaultSubscriptionPrice").removeClass("strikeTroughPackage").addClass("nostrikeTroughPackage");
}
jQuery("#applyPromoCode").html("Apply");
return false;
} else {
for ( var i in dataj.value) {
billingPlan = dataj.value[i]["packageId"];
var returnBillingPlanType = dataj.value[i]["packageType"];
var packageDiscountPrice = 0;
packageDiscountPrice = dataj.value[i]["discountedSubscriptionPrice"];
if(billingPlanType == "W" && billingPlanType == returnBillingPlanType){
if(packageDiscountPrice == "0.0"){
jQuery("#weekTrialPromoResult").text('');
}else{
jQuery("#failedCreditCard").text('');
jQuery("#weekTrialPromoResult").text("Updated subscription price is only $"+packageDiscountPrice+" per month after trial.").css({"display": "block", "color": "green", "font-size" : "12px", "font-weight" : "bold", "text-align" : "center", "padding-top" : "10px", "padding-bottom" : "10px"});
}
}else{
discountPrice = (packageDiscountPrice * 1).toFixed(2);
if (discountPrice != "0.00") {
jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text("").css("display","none");
jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text('$' + discountPrice).css({"display":"inline","visibility":"visible"});
jQuery("#"+billingPlan+".package span#billingDefaultSubscriptionPrice."+billingPlan).css("text-decoration", "line-through").addClass("strikeTroughPackage").removeClass("nostrikeTroughPackage");
if ( i == 0) {
var defaultYearPrice = 659.35;
var yearlySaving = defaultYearPrice - discountPrice;
yearlySaving = (yearlySaving * 1).toFixed(2);
var monthlyPrice = (yearlySaving/12);
monthlyPrice = (monthlyPrice * 1).toFixed(2);
jQuery("#y_monthlyprice").text(monthlyPrice);
jQuery("#y_saving").text(yearlySaving);
jQuery("#y_saving2").text(yearlySaving).css("display","inline");
jQuery("#y_saving2_li").css("display","inline");
}
} else {
jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text("").css("display","none");
jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text("").css("display","none");
jQuery("#"+billingPlan+".package span#billingDefaultSubscriptionPrice."+billingPlan).removeClass("strikeTroughPackage").addClass("nostrikeTroughPackage").css("text-decoration", "none");
if (i == 0) {
jQuery("#y_monthlyprice").text(jQuery("#y_monthlyprice_default").val()).css("background-color","#FFDEA6");
jQuery("#y_saving").text(jQuery("#y_saving_default").val()).css("background-color","#FFDEA6");
jQuery("#y_saving2").text('').css("display","none");;
jQuery("#y_saving2_li").css("display","none");
}
}
}
if(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text() != ""){
jQuery("#afterDiscountPrice").val(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPriceAjax."+billingPlan).text());
}else if(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text() != ""){
jQuery("#afterDiscountPrice").val(jQuery("#"+billingPlan+".package span#billingDiscountedSubscriptionPrice."+billingPlan).text());
}
}
}
jQuery("#applyPromoCode").html("Apply");
return true;
}
} else {
jQuery("#promoResults").text("Invalid promo code.").css({
"display": "block",
"color": "red"
});
jQuery("#applyPromoCode").html("Apply");
return false;
}
};
getDiscountPrice();
});