自定义字段的bootstrap表单验证

时间:2016-08-01 13:24:00

标签: angularjs html5 twitter-bootstrap-3 angular-ui-bootstrap

我的html中有自定义输入字段

<form role="form" class="container">
<div class="form-group">
    <label for="slNotificationType" class="control-label">Notification Type</label>
    <select id="slNotificationType" class="form-control" ng-model="inputNotificationData.notificationType"
    data-error="Please select an option" required>
        <option value="" selected hidden>Select Notification type</option>
        <option>Email</option>
    </select>
    <div class="help-block with-errors"></div>
</div>
<div class="form-group">
    <label for="btnCategory">Notification Category</label>
    <div class="form-control" required>
        <label>
            <input type="button" ng-click="showCategories()" value="Select Category">
                Selected :{{selectedCategory.name==null ? 'None' : selectedCategory.name}}
        </label>
    </div>
    <div class="help-block with-errors"></div>
</div>
...
...

在showCategories()函数中,我显示了一个弹出窗口,用户可以在其中选择一个类别。此弹出窗口以表格格式显示从服务器获取的类别列表。选择类别后,将关闭弹出窗口,并将选定的类别分配给变量selectedCategory。 作为表单验证的一部分,我想检查用户是否选择了任何类别。在表单中的其他输入字段中,如果我放置&#34; required&#34;属性,bootstrap将验证并显示验证错误消息。但是如何将required属性放在类型按钮的输入上?

基本上,我正在尝试创建一个行为类似于<input type ="file">的自定义控件,但我没有显示文件浏览器,而是拥有自己的弹出窗口来选择一个类别。

0 个答案:

没有答案
相关问题