Skip to main content
edited tags
Link
spinodal
  • 4k
  • 3
  • 32
  • 39
edited tags
Link
Yorgo
  • 2.7k
  • 1
  • 17
  • 25
Source Link
Yorgo
  • 2.7k
  • 1
  • 17
  • 25

ASP.Net MVC 3 validation on AjaxForm

I have an ajax form on razor view engine. For validation i use dataanotation classes. Validation work fine when user submit the form, validation messages work fine. The problem is, validation wont work on keyup or blur events.

How can i activate validation without submit on ajaxform(ajax.beginform)

Here is my view code:

@using (Ajax.BeginForm(new AjaxOptions { InsertionMode = InsertionMode.Replace,       
        UpdateTargetId = "employeeDetail", HttpMethod = "Post", OnComplete = "Complete", 
        Confirm = "Confirm?" }))
{
    @Html.TextBoxFor(model => model.Email)
    @Html.ValidationMessageFor(model=>model.Email)
    <span style="float:right"><input type="submit" class="tableGenelButton" id="submitButton" value="Kaydet" /></span>
}

Model:

  [RequiredWithMessage]
  [Display(Name = "E-Mail")]
  public string Email { get; set; }