I use jQuery Validation Plugin and I want to validate some hidden/disabled fields besides the other fields. Although every fields can be validated properly, I have some trouble with the hidden/disabled fields. At this point:
1) I hide a Textbox field according to the value of a Dropdownlist selected value. Which method is better for validating this field: disabled=true/false or hide/show? Or both of them at the same time?
2) For the Textbox field that will be hidden/disabled according to the Dropdownlist value, should I make this Required in the related Entity model as the other ones? If yes, the same field is assumed a mandatory field and tried to be validated even if it is hidden/disabled.
3) On the other hand, when I do not use required for the related field on in the Entity model, it is not validated even if I typed it as below:
jQuery(function () {
    $("#myform").validate({
        onfocusout: false,
        rules: {
            'Applicant.workingSoot': "required"
        },
        messages: {
            'Applicant.workingSoot': {
                required: "Make is required!"
            }
        },
        submitHandler:
            $("#myform").on('submit', function () {
                if ($("#myform").valid()) {
                    //Do something here
                    alert("Validation passed");
                }
                return false;
            })
    });
});
Note: I use the javascripts for validation with the given order below:
<script src="~/Scripts/jquery-2.0.3.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
UPDATE
Layout.cshtml:
<script src="~/Scripts/jquery-2.0.3.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
View:
<script type="text/javascript">   
    //It is used for show/hide fields according to the related 
Dropdownlist selected value
    function showHideWorking() {
        var $index = $('#isWorking').val();
        if ($index == '31') {          
            $('#workingSoot').show(); 
            $('#lbworkingSoot').show(); 
            $('#workingCity').show(); 
            $('#lbWorkingCity').show(); 
            //disabling fields in addition to hiding
            $('#lbworkingSoot').disabled = false;
            $('#workingCity').disabled = false;
            //            
        }
        else {
            $('#workingSoot').hide(); 
            $('#lbworkingSoot').hide();
            $('#workingSoot').val(""); 
            $('#workingCity').hide(); 
            $('#lbWorkingCity').hide(); 
            $('#workingCity').val(""); 
            //disabling fields in addition to hiding
            $('#lbworkingSoot').disabled = true;
            $('#workingCity').disabled = true;
            //
        }
    }
</script>
<script type="text/javascript">
/* <![CDATA[ */   /* Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA. */
jQuery(function () {
    $.validator.setDefaults({
        // options for all forms on page
    });
    $("#addForm").validate({
        onfocusout: false,
        rules: {
            'Applicant.identityNumber': "required",
            'Applicant.name': "required",
            'Applicant.surname': "required",
            'Applicant.telephone': "required",
            'Applicant.email': "required",
            'Applicant.organization': "required",
            'Applicant.hasDoneAnyProject': "required",
            'Applicant.isInterestedAnyProgramme': "required",
            'Applicant.meetingId': "required",
            'Applicant.isWorking': "required",
            //displayed & hidden fields:
            'Applicant.workingSoot': "required",
            'Applicant.workingCity': "required" 
        },
        submitHandler:
            $("#addForm").on('submit', function () {
                if ($("#addForm").valid()) {
                    //Do something here
                    alert("Validation passed");
                }
                return false;
            })
    });
});
/* ]]> */
@using (Html.BeginForm("Add", "Applicant", FormMethod.Post,
new { id="addForm", enctype = "multipart/form-data" }))
{    
    <div class="container">
        <fieldset>
            @Html.LabelFor(m=>m.Applicant.IdentityNumber)
            @Html.TextBoxFor(m => m.Applicant.IdentityNumber, new { maxlength = 11, name = "identityNumber", id = "identityNumber", @class = "numbers_only" }) 
            @Html.ValidationMessageFor(m => m.Applicant.IdentityNumber, null , new { @class = "ValidationErrors" })
            @Html.LabelFor(m=>m.Applicant.Name)
            @Html.TextBoxFor(m => m.Applicant.Name, new { maxlength = 30, name = "name", id = "name", @class = "letters_only" })
            @Html.ValidationMessageFor(m => m.Applicant.Name, null , new { @class = "ValidationErrors" }) 
            @Html.LabelFor(m=>m.Applicant.Surname)
            @Html.TextBoxFor(m => m.Applicant.Surname, new { maxlength = 30, name = "surname", id = "surname", @class = "letters_only" })
            @Html.ValidationMessageFor(m => m.Applicant.Surname, null , new { @class = "ValidationErrors" })
            @Html.LabelFor(m=>m.Applicant.Telephone)
            @Html.TextBoxFor(m => m.Applicant.Telephone, new { maxlength = 11, name = "telephone ", id = "telephone", @class = "phone_uk" })
            @Html.ValidationMessageFor(m => m.Applicant.Telephone, null , new { @class = "ValidationErrors" })
            @Html.LabelFor(m=>m.Applicant.Email)
            @Html.TextBoxFor(m => m.Applicant.Email, new { maxlength = 50, name = "email", id = "email" })
            @Html.ValidationMessageFor(m => m.Applicant.Email, null , new { @class = "ValidationErrors" })
        </fieldset>
        <fieldset>
            @Html.LabelFor(m=>m.Applicant.IsWorking)
            @Html.DropDownListFor(m => m.Applicant.IsWorking, new SelectList(Model.Lookups.Where(x => x.LookupType == "Working"),
           "LookupID", "LookupValue"), "---- Select ----", new { name = "isWorking", id = "isWorking", onchange="showHideWorking()"}) 
            @Html.ValidationMessageFor(m => m.Applicant.IsWorking, null , new { @class = "ValidationErrors" })
            @Html.LabelFor(m=>m.Applicant.WorkingSoot, new { name = "lbworkingSoot", id = "lbworkingSoot" })
            @Html.TextBoxFor(m => m.Applicant.WorkingSoot, new { maxlength = 50, name = "workingSoot", id = "workingSoot" })
            @Html.ValidationMessageFor(m => m.Applicant.WorkingSoot, null , new { @class = "ValidationErrors" })
            @Html.LabelFor(m=>m.Applicant.WorkingCity, new { name = "lbWorkingCity", id = "lbWorkingCity"})
            @Html.DropDownListFor(m => m.Applicant.WorkingCity, new SelectList(Model.Cities,
           "CityID", "CityName"), "---- Select ----", new { name = "workingCity", id = "workingCity"}) 
            @Html.ValidationMessageFor(m => m.Applicant.WorkingCity, null , new { @class = "ValidationErrors" })
        </fieldset>      
        <input id="submitbtn" type="submit" value="Send" class="button" />
    </div>     
}
 
     
     
    