function formSubmitOnlyOnce(thisform)
{
disable_submit();
if( thisform.ggclubradio )
{
var selectedValue = null;
var rbGroup = thisform.ggclubradio;
if(rbGroup.length)
{
for(var i = 0; i < rbGroup.length; i++)
{
if(rbGroup[i].checked)
{
selectedValue = rbGroup[i].value;
}
}
}
if( selectedValue == null )
{
alert("Please scroll up and select (yes or no) if you \n would like a free trial to the Guitar God Club.");
enable_submit();
return false;
}
}
if (validate_required(thisform.firstname.value,"Please enter your FIRST NAME.")==false)
{ enable_submit(); return false;}
if (validate_required(thisform.lastname.value,"Please enter your LAST NAME.")==false)
{ enable_submit(); return false;}
if (emailcheck(thisform.email1.value)==false)
{ enable_submit(); return false;}
if (emailvalidate(thisform.email1.value,thisform.email2.value)==false)
{ enable_submit(); return false;}
if (validate_required(thisform.phone.value,"Please enter your PHONE NUMBER.")==false)
{ enable_submit(); return false;}
if ((thisform.phone.value==null)||(thisform.phone.value=="")){
alert("Please Enter your Phone Number");
thisform.phone.focus();
enable_submit();
return false;
}
/*
if (checkInternationalPhone(thisform.phone.value)==false){
alert("Please Enter a Valid Phone Number");
thisform.phone.value="";
thisform.phone.focus();
return false;
}
*/
if (validate_required(thisform.address.value,"Please enter your ADDRESS - Billing.")==false)
{ enable_submit(); return false;}
if (validate_required(thisform.city.value,"Please enter your CITY - Billing.")==false)
{ enable_submit(); return false;}
if (validate_required(thisform.zip.value,"Please enter your ZIP - Billing.")==false)
{ enable_submit(); return false;}
if (validate_required(thisform.state.value,"Please enter your STATE - Billing.")==false)
{ enable_submit(); return false;}
if (state_country_check(thisform.state.value,thisform.country.value, "Billing")==false)
{ enable_submit(); return false;}
if(document.getElementById('e_frm_shipping_billing_address_same').checked == false){
if (validate_required(document.getElementById("e_frm_shipping_address").value,"Please enter your ADDRESS - Shipping.")==false)
{enable_submit(); return false;}
if (validate_required(document.getElementById("e_frm_shipping_city").value,"Please enter your CITY - Shipping.")==false)
{ enable_submit(); return false;}
if (validate_required(document.getElementById("e_frm_shipping_zip").value,"Please enter your ZIP - Shipping.")==false)
{ enable_submit(); return false;}
if (validate_required(document.getElementById("e_frm_shipping_state_ref").value,"Please enter your STATE - Billing.")==false)
{ enable_submit(); return false;}
state_country_check(document.getElementById("e_frm_shipping_state_ref").value,document.getElementById("e_frm_shipping_country_ref").value, "Shipping");
}
/*
if (validate_required(thisform.ccnumber.value,"Please enter your CARD NUMBER.")==false)
{return false;}
if (validate_required(thisform.cvv.value,"Please enter your SECURITY CODE (CVV).")==false)
{return false;}
*/
return true;
}
function state_country_check(state,country,type){
if(state=="none" && (country=="US" || country=="CA")){
alert("Please choose a STATE for US/CANADA - " + type + ".");
return false;
}
if(state!="none" && (country!="US" && country!="CA")){
alert("Please choose 'Outside of US/Canada' for STATE - " + type + ".");
return false;
}
return true;
}
function ltrim(stringToTrim) {
return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
return stringToTrim.replace(/\s+$/,"");
}
function validate_required(field,alerttxt){
var fval = trim(field);
if (fval==null||fval=="")
{alert(alerttxt);return false;}
else {return true}
}
function emailvalidate(str1, str2){
if(str1 != str2){
alert("Please CONFIRM EMAIL. Entries DO NOT MATCH.");
return false;
}
else {return true;}
}
function emailcheck(str) {
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);
if (str.indexOf(at)==-1){
alert("Invalid EMAIL ADDRESS");
return false;
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid EMAIL ADDRESS");
return false;
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid EMAIL ADDRESS");
return false;
}
if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid EMAIL ADDRESS");
return false;
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid EMAIL ADDRESS");
return false;
}
if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid EMAIL ADDRESS");
return false;
}
if (str.indexOf(" ")!=-1){
alert("Invalid EMAIL ADDRESS");
return false;
}
return true;
}
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function trim(s)
{ var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not a whitespace, append to returnString.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (c != " ") returnString += c;
}
return returnString;
}
function stripCharsInBag(s, bag)
{ var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function onTrialDenied(radiobutton)
{
if( radiobutton.checked )
{
if( confirm("There is nothing to lose by accepting this free trial...\n You can cancel anytime even if you want to \n cancel immediately and just enjoy the first free month. \n Wouldnt you like the free trial ? (Click Ok to Accept, Cancel to Decline)"))
{
var rb = document.getElementById("ggclubradio_yes");
if( rb )
{
rb.checked = "checked";
}
}
}
}
function disable_submit(){
document.getElementById("submitbtn").disabled = 'true';
document.getElementById("submitbtn").src = 'https://www.guitarcontrol.com/gcproducts/images/Place-Your-Order-300x100-disabled.png';
document.getElementById("loader").style.display = 'block';
}
function enable_submit(){
document.getElementById("submitbtn").disabled = false;
document.getElementById("submitbtn").src = 'https://www.guitarcontrol.com/gcproducts/images/Place-Your-Order-300x100.png';
document.getElementById("loader").style.display = 'none';
}