1
votes

i have below form

 @using (Html.BeginForm("register", "users"))
{
<p>
    First Name
</p>
<div>
    @Html.TextBoxFor(x => x.FirstName)
    @Html.ValidationMessageFor(x => x.FirstName)
</div>
</div>
<div class="input_block">
    <p>
        Last Name <span class="required">*</span></p>
    <div>
        @Html.TextBoxFor(x => x.LastName)
        @Html.ValidationMessageFor(x => x.LastName)
    </div>
</div>
<div class="input_block">
    <p>
        CV <span class="required">&nbsp;</span></p>
    <input type="file" name="Cv" class="w_265" data-val-remote="&amp;#39;Cv&amp;#39; is invalid."
        data-val-remote-additionalfields="*.Cv" data-val-remote-url="/Validation/IsUID_Available" />
</div>

}

in the above form all fields other than "CV" field uses "asp .net mvc3 Unobtrusive JavaScript validation for client side validation"

for "Cv" i manually gave the validation attributes (data-val-remote,data-val-remote-url,data-val-remote-additionalfields)

so that the remote validation happens for "Cv", but when i submit the form all the fields are validated except "Cv" field, i mean client side validation is not triggered for "Cv" field.

i am using fluent validation for server side validation

please help me

Thanks

1
did you give the Remote attribute on Model Class ??Furqan Hameedi
@Furqan He doesn't have to, he did it manually with the data-val-remote attributes.MHollis
I am curious why you manually wrote the unobtrusive attributes. Why not use the built-in stuff?Andy_Vulhop

1 Answers

0
votes

It appears you forgot the data-val="true" attribute in your input type="file" tag. data-val="true" is required for the unobtrusive validation script to even look at the other attributes. Without it the script completely ignores the input.