无法在元素下面放置错误

时间:2016-06-08 17:03:35

标签: jquery twitter-bootstrap

我想使用errorLabelContainer将错误置于选择元素'term'之下,但它运行不正常,不知道我做错了什么

enter image description here

名称字段

<div class="form-group"> 
    <label class="control-label" style="margin-bottom: 5px;">Calendar Name </label>
    <input type ="text" name="calendar_name" class="form-control" data-validate="required" data-message-required="Value Required" />
</div>

术语字段

<div class="form-group">
    <label class="control-label" style="margin-bottom: 5px;">Term</label>
    <select name="term" id="term" class="form-control selectboxit" data-validate="required" data-message-required="Please select a term" >
        <option value=""><?php echo get_phrase('select_term');?></option>
        <option value="1"><?php echo get_phrase('1st_term');?></option>
        <option value="2"><?php echo get_phrase('2nd_term');?></option>
        <option value="3"><?php echo get_phrase('3rd_term');?></option>
    </select>
    <label id = "myerror"> </label>
</div>

Javascript

<script type ="text/javascript">

$(document).ready(function(){
     $.validator.setDefaults({ ignore: ':hidden:not(.selectboxit)'   });

 $('#term').validate({ 
        rules: {
            'term': {
                required: true
            }
        },
        messages: {
            'term': {
                required: 'Please select a term'
            }
        },
        errorLabelContainer:'#myerror',

    });

});
</script>

0 个答案:

没有答案