I wrote this form up, it works fine, except for the checkbox which is supposed to replicate the address values. No matter, how I write, rewrite, and correct it. It simply will not work.
The first portion of the code is the form, the second part has the replication portion of code, and the third part is an unrelated mask.
$(document).ready(function () {
//Any hidden errors that were passed back from 4D?
// for signup forms, we need to see which form we will show the errors on
if ($("#referralForm1").is(":visible")){
show4DErrors("#referralForm1");
}
$("#referralForm1").validate({
rules: {
Referral_Name_T: "required",
Referral_Company_T: "required",
Referral_Address_T: "required",
Referral_City_T: "required",
Referral_State_T: "required",
Referral_Zip_T: {
required: true,
zipCode: true
},
Referral_PhoneFull_T: {
required: true,
phoneNumber: true
},
Referral_Email_T: {
required: true,
email: true,
},
Referral_EmailConfirm_T: {
required: true,
email: true,
equalTo: "#Referral_Email_T"
},
Referral_PayToName_T: "required",
Referral_PayToAddress_T: "required",
Referral_PayToCity_T: "required",
Referral_PayToState_T: "required",
Referral_PayToZip_T: {
required: true,
zipCode: true
},
}
});
$("Referral_SameAsAbove_T").click(function(){
if ($("Referral_SameAsAbove_T").is(':checked'))
{
// Checked, copy values
$("#Referral_PayToAddress_T").val($("#Referral_Address_T").val());
$("#Referral_PayToCity_T").val($("#Referral_City_T").val());
$("#Referral_PayToState_T").val($("#Referral_State_T").val());
$("#Referral_PayToZip_T").val($("#Referral_Zip_T").val());
}
else
{
// Clear on uncheck
$("#Referral_Address_T").val("");
$("#Referral_City_T").val("");
$("#Referral_State_T").val("");
}
});
//Mask Setup
$('#Referral_PhoneFull_T').mask('(999) 999-9999');
$('#Referral_Zip_T').mask('99999');
$('#Referral_PayToZip_T').mask('99999');
});
Looks like your selector is wrong
EDIT
Handle the change event for the textbox..
FIDDLE
NOTE : This is just to handle the change event for PayToAddress_T textbox. For other’s