The*_*ngI 3 forms jquery twitter-bootstrap
我在stackoverflow上的第一篇文章,所以要温柔.我是一个新手学习者:)我使用Twitter Bootstrap构建表单3.在该表单中,我有一个下拉列表,允许用户选择国家.我的问题是:如何将其作为"必需"字段?如果跳过该字段,我不希望提交表单.我正在使用"必需"字段,它适用于基本文本类型.
<input type="text" class="form-control" placeholder="Enter Name..." required />
Run Code Online (Sandbox Code Playgroud)
但我不知道在使用下拉列表时我在哪里插入"必需".我试图用任何额外的jquery/js来做这件事.已经包含了jquery-1.10.2.js和bootstrap.js
请帮忙.
必需属性可以添加到select元素.从你的例子:
<div class="form-group">
<label for="country" class="col-sm-3 control-label">Country *</label>
<div class="col-sm-6">
<select id="country" name="country" class="form-control" required>
Run Code Online (Sandbox Code Playgroud)
为了完整性,我还在select元素中添加了id和name属性.