0

I have view with multiple submit button in ASP.NET MVC and I want validate the form using data annotations, but when user clicks on a particular button, not all submit button, validation must be performed with particular button not all button on view.

@using (Html.BeginForm("Index", "Skill", FormMethod.Post))
{
   @Html.ValidationSummary(true)
   @Html.AntiForgeryToken()
   @Html.TextBoxFor(model => model.SkillName)
   @Html.HiddenFor(model => model.SkillId)
   @Html.ValidataionSummaryFor(model => model.SkillName)

   <input type="submit" name="AddAction" value="Add" id="btnAdd"/>
   <input type="button" name="btnreset" value="Reset" />
}

I want that validation will apply only on Add button not on Next button or any button

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Riyaz
  • 1
  • 1

1 Answers1

0

You can you put "NoValidation" Buttons outside form. This will solve the issue. If you still need form data, you can serialize it via JS, like this:

$("form").serialize()

and send to server.

teo van kot
  • 12,350
  • 10
  • 38
  • 70
  • but how can i decide that validation must perform on this particular button while i use $("form").serialize() please help thanks a lot – Riyaz Nov 06 '14 at 10:27
  • @Riyaz Well, if you really want to turn off validation with js, one of the ways here http://stackoverflow.com/a/7391785/1849444 or here http://stackoverflow.com/a/12179373/1849444 – teo van kot Nov 06 '14 at 10:33
  • Thanks a lot,But i don't want to turn off validation but want to apply validation when user click only particular button – Riyaz Nov 06 '14 at 11:45