条件付きで Html.BeginForm を使用したい。以下のようにコード内に2つのフィールドがあります
@using (Html.BeginForm("Form1Action", "Form1", FormMethod.Post, new { id = "form1" }))
{
<label for="firstlabel">Label 1</label>
<input type="text" id="firstlabel" name="firstlabel"/>
<label for="secondlabel">Label 2</label>
<input type="text" id="secondlabel" name="secondlabel"/>
<a href="#" class="button" onclick="SubmitForm();">Submit</a>
}
そしてJSは
<script type="text/javascript">
function SubmitForm() {
$('#form1').submit();
}
</script>
secondlabel が空白または空の場合、別のアクションでフォームを送信したいのですが、どうすればこれを実現できますか?
別のアクションとは、つまり:
@using (Html.BeginForm("Form2Action", "Form2", FormMethod.Post, new { id = "form2" }))