我使用下面的代码但是在我的表单提交中出现验证错误后,readonly属性丢失了 我正在为ajax中的文本框设置readonly prop,但在完成之后就丢失了。
if (txnDate != undefined && txnDate != 'undefined' && schCode != '0' && schCode != undefined)
{
$("#updateProgress").dialog("open");
$.ajax({
url: '@Url.Content("~/AddExtPortfolio/MFSelectOnChange")' + '?txnType=' +
selectedOption + &brkCode='brkCode + '&amcCode=' + amcCode + '&schCode=' + schCode +
'&txnDate=' + txnDate + '&ID=' + ID,
Type: 'POST',
datatype: 'json',
contentType: 'application/json; charset=utf-8',
success: function (data) {
if (
selectedOption == "Buy" ||
selectedOption == "SIP" ||
selectedOption == "Redeem" ||
selectedOption == "Switch" ||
selectedOption == "STP" ||
selectedOption == "SWP" ||
selectedOption == "DR")
{
if (selectedOption == "Buy") {
NAV = $("#MutualFundList_" + ID + "__TxnNAV");
NAV_Value = data.MutualFundList[ID].TxnNAV;
}
else if (selectedOption == "SIP") {
NAV = $("#MutualFundList_" + ID + "__TxnNAVSIP");
NAV_Value = data.MutualFundList[ID].TxnNAVSIP;
}
else if (selectedOption == "Redeem" || selectedOption == "Switch" || selectedOption == "STP" || selectedOption == "SWP") {
ExtUnits = $("#add_external_form_" + selectedOption + "_" + ID + " #MutualFundList_" + ID + "__ExtUnits" + selectedOption);
ExtAmt = $("#add_external_form_" + selectedOption + "_" + ID + " #MutualFundList_" + ID + "__ExtAmount" + selectedOption);
}
if (selectedOption == "Redeem") {
ExtUnits.val(data.MutualFundList[ID].ExtUnitsRedeem);
//ExtAmt.val(data.MutualFundList[ID].ExtAmountRedeem);
NAV = $("#add_external_form_" + selectedOption + "_" + ID + " #MutualFundList_" + ID + "__TxnNAVRedeem");
NAV_Value = data.MutualFundList[ID].TxnNAVRedeem;
var new_redeem_amount = data.MutualFundList[ID].ExtUnitsRedeem * NAV_Value;
if (NAV_Value != 0) {
ExtAmt.val(new_redeem_amount);
}
else {
ExtAmt.val(new_redeem_amount);
$(NAV).change(function () {
result = $(ExtUnits).val() * $(NAV).val();
result = Math.round(result * 100) / 100;
$(ExtAmt).val(result);
});
}
}
NAV.val(NAV_Value);
if (NAV_Value == null || NAV_Value == 0) {
$(NAV).prop("readonly", false);
}
else {
$(NAV).prop("readonly", true);
if (selectedOption != 'Buy' && selectedOption != 'SIP' && selectedOption != 'DP') {
GetAmtUnits(ID, "");
}
}
}
}
});/*end of ajax call*/
}