Hello,
I am trying to use the Client-side Validation with jQuery in ASP.NET MVC (2). I've found this great example
which works fine but I am having problems when I try to use a custom name for my form.
It seems that the EnableClientValidation methods uses the default form name "form0" to inject the client script and doesn't support any other name.
Here's a code sample of what I am trying to do:
<%=Html.ValidationSummaryJQuery("Please fix these errors.", "id", "BPValidationID")%>
<% Html.EnableClientValidation()%>
<% Using (Html.BeginForm("Edit", "Home", New With {.Id = Model.Code}, FormMethod.Post, New With {.id = "EditForm"}))%>
<% ViewContext.FormContext.ValidationSummaryId = "BPValidationID"%>
<%=Html.AntiForgeryToken("AF-BP-SPED-token")%>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%=Html.LabelFor(Function(m) m.Name)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(Function(m) m.Name)%>
<%=Html.ValidationMessageFor(Function(m) m.Name, "*")%>
</div>
<p>
<input type="submit" name="submitButton" value="Save" />
</p>
</fieldset>
<%End Using%>
Is there any chance for me to use a FORM name, in case I want to use multiple forms on my page?
Thanks for any help,
Alberto