Note that there are some explanatory texts on larger screens.

plurals
  1. POCombining MicrosoftMvcJQueryValidation and Ajax Submit
    primarykey
    data
    text
    <p>I'm having troubles trying to apply MS JQuery Validation in my forms where I want to submit data via an Ajax call. I am using DataAnnotations and MicrosoftMvcJQueryValidation.js library to perform client-side and server-side validation.</p> <p>Server validation works great and I'm trying to enable Client validation by mean of</p> <pre><code> &lt;% Html.EnableClientValidation(); %&gt; &lt;%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %&gt; &lt;div id="formContainer"&gt; &lt;% using(Html.BeginForm()){ %&gt; &lt;table class="formTable" width="100%" border="0" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="Description"&gt;Description:&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;%= Html.TextBox("Description", Model.Description) %&gt; &lt;%= Html.ValidationMessage("Description", "*") %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;%=Html.Button("cancelBtn","Cancel")%&gt; &lt;input id='createBtn' class='button' type='button' value='Create' /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;% } %&gt; &lt;/div&gt; </code></pre> <p>The onclick event is then managed via a custom Ajax call. In my page source I can see the section</p> <pre><code>//&lt;![CDATA[EnableClientValidation(...)] </code></pre> <p>but I would like to validate data before the actual Ajax call.</p> <p>At the contrary by using a submit input and </p> <pre><code>inputCreate.submit(function () {$.ajax...}); </code></pre> <p>client-side validation is performed but no ajax-call is performed, form is submitted via postback.</p> <p>Is there any way to make them work together without changing jQuery.validate library?</p> <p>Is it possible? Am I using a wrong approach to this?</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload