我写了这个表格,它工作正常,除了应该复制地址值的复选框。不管我怎么写,改写,改正。它根本行不通。
代码的第一部分是表单,第二部分是代码的复制部分,第三部分是不相关的掩码。
$(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');
});