Hi,
This is my view
| Does the school have staff houses? |
@Html.RadioButtonFor(model =>
model.charSchoolHaveStaffHouses, "Y", new { onclick =
"StaffHouses_Click()", name = "rdoSchStaffHostel", id =
"rdoSchStaffHousesY" })Yes
@Html.RadioButtonFor(model =>
model.charSchoolHaveStaffHouses, "N", new {onchanged="valid()", onclick =
" $(this).resetValidation()" })No
@Html.ValidationMessageFor(model => model.charSchoolHaveStaffHouses)
|
| How many Staff Houses does the school have? |
@Html.TextBoxFor(model => model.intStaffHousesCount,
new { disabled = "disabled", maxlength = 4, onkeypress = "return
validate(event)", @class = "myStyle" })
@Html.ValidationMessageFor(model => model.intStaffHousesCount)
|
| No Of Workers in the Staff Houses |
@Html.TextBoxFor(model =>
model.intWorkersCountInStaffHouses, new { disabled = "disabled",
maxlength = 4, onkeypress = "return validate(event)", @class = "myStyle"
})
@Html.ValidationMessageFor(model => model.intWorkersCountInStaffHouses)
|
and I am calling JavaScript functions in this view as follows
function StaffHouses_Click() {
var radio1 = document.getElementById("rdoSchStaffHousesY");
var radio2 = document.getElementById("charSchoolHaveStaffHouses");
if (radio1.checked == true) {
document.getElementById("intStaffHousesCount").disabled = false;
document.getElementById("intWorkersCountInStaffHouses").disabled = false;
}
else {
document.getElementById("intStaffHousesCount").disabled = true;
document.getElementById("intWorkersCountInStaffHouses").disabled = true;
document.getElementById("intStaffHousesCount").value = "";
document.getElementById("intWorkersCountInStaffHouses").value = "";
$('#intStaffHousesCount .input-validation-error').addClass('input-validation-valid');
$('#intStaffHousesCount .input-validation-error').removeClass('input-validation-error');
$('#intStaffHousesCount .field-validation-error').addClass('field-validation-valid');
$('#intStaffHousesCount .field-validation-error').removeClass('field-validation-error');
$('#intStaffHousesCount .validation-summary-errors').addClass('validation-summary-valid');
$('#intStaffHousesCount .validation-summary-errors').removeClass('validation-summary-errors');
//$('#field-validation-error ui-state-error-icon ui-icon-alert').removeClass.
//document.getElementById("intStaffHousesCount").onerror.value.disabled = true;
}
}
So In this I want to clear the validation errors when the control is in
disable mode i.e when the radio button which is mentioned in the
starting when we click on no 2 textboxes should be disabled and error
providers should be cleared.So please provide solution for this??
Thanks in advance