.NETMVC3:Form不';不要在JQuery代码之后提交

.NETMVC3:Form不';不要在JQuery代码之后提交,jquery,asp.net-mvc-3,form-submit,Jquery,Asp.net Mvc 3,Form Submit,我有一个简单的表单,有两个字段和一个可选字段,选中复选框时显示该字段,如果未选中复选框则隐藏该字段-显示/隐藏由jQuery控制。问题是,当第一次加载页面时,表单会像往常一样提交,但一旦选中或取消选中复选框,提交按钮就不会提交表单,甚至更奇怪的是,它什么也不做 我有一个模型为的强类型视图: @model Metteem.ViewModels.SchedularAccount 我的简单脚本是: <script type="text/javascript"> $(document).r

我有一个简单的表单,有两个字段和一个可选字段,选中复选框时显示该字段,如果未选中复选框则隐藏该字段-显示/隐藏由jQuery控制。问题是,当第一次加载页面时,表单会像往常一样提交,但一旦选中或取消选中复选框,提交按钮就不会提交表单,甚至更奇怪的是,它什么也不做

我有一个模型为的强类型视图:

@model Metteem.ViewModels.SchedularAccount
我的简单脚本是:

<script type="text/javascript">
$(document).ready(function () {
    $("#showhide").click(function () {
        $("#alternatingInput").toggle('fast');
    });
});
</script>

会出现什么问题?

多亏了@avesse,在提交时添加类型解决了这个问题

如果必须使用,请尝试
一个
元素


您是否启用了客户端验证?按钮不应该是“提交”按钮吗?i、 e
?@gdoron Firebug没有提供任何线索。不幸的是,唯一的变化是,当复选框未选中时,显示选项为block,而当复选框未选中时,显示选项为none:
@DarinDimitrov是,客户端验证已启用。虽然这并不重要,因为它不是因为空的隐藏文本框,但如果它被填充,则情况不会改变。如果必须使用
元素,请尝试
@using (Html.BeginForm(null, null, FormMethod.Post, new { Class = "well form-horizontal" }))
{
    <fieldset>
        <div class="control-group">
            <label class="control-label">Meeting ID</label>
            <div class="controls">
                @Html.TextBoxFor(model => model.MeetingId, new { Class = "input-xlarge" })
                @Html.ValidationMessageFor(model => model.MeetingId, null, new { Class = "help-inline" })
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Password</label>
            <div class="controls">
                @Html.PasswordFor(model => model.Password, new { Class = "input-xlarge" })
                @Html.ValidationMessageFor(model => model.Password, null, new { Class = "help-inline" })
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">Login as Host?</label>
            <div class="controls">
                @Html.CheckBoxFor(model => model.IsHost, new { Class = "input-xlarge", id = "showhide" })
            </div>
        </div>
        <div class="control-group" id="alternatingInput" style="display: block; ">
            <label class="control-label">Participant ID</label>
            <div class="controls">
                @Html.TextBoxFor(model => model.UserId, new { Class = "input-xlarge", Value = "0" })
            </div>
        </div>

    </fieldset>
    <div class="form-actions">
        @Html.ActionLink("Cancel", "Index", "Home", null, new { Class = "btn" })
        <button class="btn btn-primary">Login</button>
    </div>
}
[HttpPost]
public ActionResult HostParticipantLogin(SchedularAccount account)
{
   //Rest of my code
}