检查是否填写了所有必需的输入并自动提交表单

时间:2016-05-04 09:22:12

标签: jquery forms

在我的表单中,我希望在填写完所有必填字段(.required-entry)后,自动提交表单而不点击提交按钮。

<div id="billing-form">
    <fieldset>
        <div class="field form-group">
            <input type="text" class="input-text form-control required-entry" id="name" />
        </div>
        <div class="field form-group">
            <input type="text" class="input-text form-control required-entry" id="mid-name" />
        </div>
    </fieldset>
</div>
<div class"button-container">
    <button type="button" title="Continue" id="btn-continue" class="button btn-continue" onclick="billing.save()">Continue</button>
</div>

1 个答案:

答案 0 :(得分:0)

当输入填充时,这是一个总结表格的坏主意,但是当填写当前表单输入时,您可以显示下一个表单。为此,请使用此代码。

#form2 {
    display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<form id="form1">     
    <div>
        <label>Form 1</label>
    </div>
    <div>
        <label>Firstname</label>
        <input type="text" />
    </div>
    <div>
        <label>Lastname</label>
        <input type="text" />
    </div>
</form>
<br />
<form id="form2">     
    <div>
        <label>Form 2</label>
    </div>
    <div>
        <label>Birthday</label>
        <input type="text" />
    </div>
    <div>
        <label>Country</label>
        <input type="text" />
    </div>
</form>
# The code you provided
LS_fit_ydata = []
for i in x_data:
    y_new = ((i*b) + a)
    LS_fit_ydata.append(y_new)

# What happens here is you're plotting x against y one by one via the list
plt.plot(x_data, y_new)
# Show the graph
plt.show()