Validating HttpPostedFileBase on client side with jquery unobtrusive
<p>I got jquery (original, validate &amp; unobtrusive) on my site. I've extended a validation attribute which works on server side, but I can not for the life of me get it to work on client side. What am I missing?</p>

<p>My model looks like this: </p>

<pre><code>[Display(Name = "UploadFile"), DataType(DataType.Upload)]
[ValidateFile]
public IEnumerable&lt;HttpPostedFileBase&gt; MyImage { get; set; }
</code></pre>

<p>I have added this attribute extension to my model:</p>

<pre><code>public class ValidateFileAttribute : ValidationAttribute 
{
    public override bool IsValid(object value)
    {
        int MaxContentLength = 1024 * 1024 * 10; //10 MB
        string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf" };
        var files = value as IEnumerable&lt;HttpPostedFileBase&gt;;

        foreach (var file in files)
        {
            if (file == null)
            {
                return false;
            }
            else if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
            {
                ErrorMessage = Resources.ResourcesAdvert.AdvertUploadFileExtensionErrorShorter + string.Join(", ", AllowedFileExtensions);
                return false;
            }
            else if (file.ContentLength &gt; MaxContentLength)
            {
                ErrorMessage = Resources.ResourcesAdvert.AdvertUploadFileTooBig + (MaxContentLength / 1024).ToString() + "MB";
                return false;
            }
            else
            {
                return true;
            }
        }
        return false;
    }
}
</code></pre>

<p>I've got a view like this: </p>

<pre><code>@Html.LabelFor(x =&gt; x.MyImage)

&lt;input type="file" name="MyImage[0]" id="MyImage1" /&gt;
&lt;input type="file" name="MyImage[1]" id="MyImage2" /&gt;
&lt;input type="file" name="MyImage[2]" id="MyImage3" /&gt;

@Html.ValidationMessageFor(x =&gt; x.MyImage)
</code></pre>

<p>My controller is working fine and it works to upload images if they are valid. Any ideas how I could proceed?</p>

<p>EDIT: I've also tried to use <a href="https://stackoverflow.com/questions/8536589/asp-net-mvc-3-dataannotations-fileextensionsattribute-not-working/13650754#13650754">this</a> , but that didn't work for me client side either and I could not manage to customize an error message.</p>