return bool;
}
$(document).ready(function(){
fixCustomFieldsNames();
submitFormAction();
$("#ib-form-fields input,#ib-ty-fields input").each(function(){
//get each fields value and add an attr to store it
var initVal = $(this).val();
$(this).attr("init-val", initVal);
$(this).focus(function(){
if($(this).val() == $(this).attr("init-val")) $(this).val("");
});
$(this).blur(function(){
if($(this).val() == "") $(this).val($(this).attr("init-val"));
});
//add the ieText class to tackle the issue on IE where the input texts dont line up and show very thin
if($(this).attr("type") != "checkbox") $(this).addClass("ieText");
});
//fix input fields for IE
$(".ibinput").css("clear", "both");
$(".ibinput").css("min-height", "35px");
$(".ibinput").css("height", "2.8em");
});
function fixCustomFieldsNames()
{
///////////////HACK for changing input names from custom_name to u_custom_x where x is a number (1-30)//////////////
/////this shud ve been solved in ibmenu.js but there are already too many lead pages out there, thats why this hack at run time//////
//get all the input fields
var ibFieldsArr = $("#ib-form-fields input[type=text]");
//some of the fields in the ibFieldsArr are standard fields like u_firstname, u_phone etc
//and some of these are custom
//separate th custom fields
var ibCustomFieldsArr = [];
//generic fields have a preceeding u_
//if the ibfields have a preceeding u_ then 'assume' that they are generic else they are custom
//this is just a HACK and it will fail in case someone created a field like 'U Something' which will create a field with a preceding u_
//anyway, here goes
for(var i=0; i
//rename fields from the custom fields to u_custom_x
for (var j=0; j
function checkSMSCheck()
{
//check if the sms check is checked in case this page has a form with a phone number
var bool = true;
if($("#sms-check").length > 0)
{
var phn = $("input[name=u_phone]").val();
var phnInitVal = $("input[name=u_phone]").attr("init-val");
var isPhnRequired = $("input[name=u_phone]").attr("required");
//ty page
if($("#ib-ty-fields").length > 0)
{
if(!$("#sms-check").is(":checked") || !isValidPhoneNum(phn) || phn.length<9 )
{
alert("You must enter a valid mobile number as well as agree to the SMS Terms of Services!");
$("input[name=u_phone]").focus();
bool = false;
return false;
}
}
//lead page
else
{
if(phn != "" && phn != phnInitVal)
{
if(!isValidPhoneNum(phn) || phn.length<9)
{
alert("Please enter a valid mobile number!");
bool = false;
return false;
}
else
{
//check if sms check is checked
if(!$("#sms-check").is(":checked"))
{
alert("You must agree to the SMS Terms of Services!");
bool = false;
return false;
}
}
}
if(isPhnRequired != undefined && isPhnRequired != false)
{
if(!isValidPhoneNum(phn) || phn.length<9 || !$("#sms-check").is(":checked"))
{
alert("You must enter a valid mobile number as well as agree to the SMS Terms of Services!");
bool = false;
return false;
}
}
}
}
return bool;
}
function emptyUnusedFields()
{
//empty fields that were not filled by the user
//get all the input fields
var ibFieldsArr = $("#ib-form-fields input[type=text]");
for(var i=0; i
}
function submitFormAction()
{
$("form[name=my_form]").submit(function(){
var bool = checkSMSCheck();
if(bool) emptyUnusedFields();
return bool;
});
}