我刚刚使用下面的jQuery代码将6个文本框值复制到另外6个带有复选框的文本框中:
jQuery(function ($) {
$('#addr').change(function () {
if ($(this).is(':checked')) {
$('#InvoiceAddress1').val($('#Address1').val());
$('#InvoiceAddress2').val($('#Address2').val());
$('#InvoiceCity').val($('#City').val());
$('#InvoiceCounty').val($('#County').val());
$('#InvoicePostCode').val($('#PostCode').val());
$('#InvoiceCountryId').val($('#CountryId').val());
} else {
$('#InvoiceAddress1').val(null);
$('#InvoiceAddress2').val(null);
$('#InvoiceCity').val(null);
$('#InvoiceCounty').val(null);
$('#InvoicePostCode').val(null);
$('#InvoiceCountryId').val(null);
}
});
});
当我在MVC项目的表单中使用上面的代码时,模型错误丢失了。如果我删除上面的代码javascript文件模型错误工作正常。有什么办法可以避免这种冲突吗?