element 0 is undefined on form post in MVC-Collection of common programming errors

I’m opening a query dialog box which has two query tabs in MVC application. both tabs loading different partial pages. I’ve form in one of tab. form validation works fine. I’m getting error $element[0] is undefined in jquery.validate.js @ line 806 when there is no validation error in form. I’m unable to understand whats issue. below is code:

    Include references in _Layout.cshtml:
        
        
        
        

Partial view which open in one of tab:
    

@using (Ajax.BeginForm("UpdateMediaCode", "MediaCode", null,
        new AjaxOptions
        {
            UpdateTargetId = "myMsg",
            InsertionMode = InsertionMode.Replace,
            HttpMethod = "POST",
            OnSuccess = "mySuccess"
        }, new { @id = "myFormId" }
        ))
{
    @Html.ValidationSummary(true) 
 }

    $(document).ready(function () {
        $.validator.unobtrusive.parse($('#myFormId));
    }

any help would be appreciated. what’s happing here?

  1. It is inside the mySuccess callback used as OnSuccess handler in your AjaxForm that you should call $.validator.unobtrusive.parse method, not inside a document.ready. You shouldn’t have a document.ready handler inside a partial. You shouldn’t have any javascript inside a partial by the way. JavaScript should be written in separate files. Partial views should contain only markup.