Bootstrap验证不起作用?

时间:2014-11-19 13:35:25

标签: twitter-bootstrap jquery-ui

我有一个在新模式下打开的表单,并且在jquery UI弹出窗口中也处于编辑模式但是当我的表单在新模式下打开时验证适用于我,但是当在编辑模式下打开相同的表单时,验证不起作用我被困在这里并且无法弄清楚出路。任何帮助??

frmSpecialtyDetail表格:

<div id="specialtyDetail">

<div class="fadeoutPatch0"></div>
<div class="fadeoutBackground" id="fbspecialtyDetail"></div>

<div id="tblspecialtyDetail" class="col-md-12">

    <form method="post" id="frmSpecialtyDetail" onsubmit="return false">
        <!--start - CONTENTS-->
        <div class="form-group">
            <div class="col-md-6">
                <label class="control-label">Short Name <span class="required">*</span></label>
                <input class="form-control size100" name="ShortName" id="txtShortName" type="text" maxlength="10" />
            </div>
            <div class="col-md-4 pad-a-labelsize">
                <div class="checkbox-custom checkbox-default">
                    <input type="checkbox" checked="" id="chkActive">
                    <label for="Active">Active</label>
                </div>
            </div>
            <div class="col-md-12">
                <label class="control-label">Description</label>
                <input class="form-control" id="txtDescription" type="text" maxlength="55" />
            </div>

        </div>
        <div class="col-md-6 pad-a-labelsize-btn">
            <div class="btn-block">
                <button class="btn btn-primary btn-sm" type="submit">Save</button>
                <!--<button class="btn btn-primary btn-sm" type="reset" onclick="specialtyDetail.SpecialtyUnload();">Cancel</button>-->
            </div>
        </div>
    </form>

</div>

<script type="text/javascript">
$(document).ready(function () {
    $('#frmSpecialtyDetail')
       .bootstrapValidator({
           message: 'This value is not valid',
           feedbackIcons: {
               valid: 'glyphicon glyphicon-ok',
               invalid: 'glyphicon glyphicon-remove',
               validating: 'glyphicon glyphicon-refresh'
           },
           fields: {
               ShortName: {
                   group: '.col-md-6',
                   validators: {
                       notEmpty: {
                           message: 'Short Name is required'
                       }
                   }
               }
           }
       })
    .on('success.form.bv', function (e) {
        e.preventDefault();
       specialtyDetail.SpecialtySave();
    });
});
</script>

1 个答案:

答案 0 :(得分:0)

下载Bootstrap Validator并实现您的代码..

这是文档

http://bootstrapvalidator.com/getting-started/