开发者

Can we have more than one submit type button in one form?

I need to implement validation for a form but by two submit buttons?

Can we do change the 'Ty开发者_StackOverflowpe' from jQuery so that it can work perfectly as i want:)


http://www.frederikvig.com/2009/06/using-multiple-forms-on-an-asp-net-web-forms-page/

http://www.c-sharpcorner.com/UploadFile/avi_sanjay/MultiForms.htm06042006062957AM/MultiForms.htm.aspx


If you are talking about client-side validation you can use JavaScript to make different buttons post to different locations (these locations can be different to validate it in more than one way on the server side) e.g.

<form name="someForm1" id="someForm1" method="POST">
.
.
.


<input type="button" name="button1" id="button1" onclick="javascript:post1();"/>
<input type="button" name="button2" id="button2" onclick="javascript:post2();"/>
</form>

Then make post1 implement one type of client-side validation (validate1()) and post2 (validate2()) the other approach. You can even use JavaScript to post to different URLs. An example of how this can be done is:

function post1()
{
  var form1=document.forms['someForm1'];
  form1.action="form1.aspx";
  if(validate1())
  {
     form1.submit();
  }
  else
  {
     invalid1();
  }    
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜