bootstrap文件上传验证无效

时间:2016-03-09 13:28:11

标签: html5 twitter-bootstrap

我正在使用bootstrap文件上传,请参阅此网站 Here 。所有验证应该在照片上传的精细execpt工作,没有选择任何字段我想显示错误消息...

<!--Firstname code-->
  <div class="form-group">
        <label class="col-md-3 control-label">First Name<span class="star_mark">&nbsp;*</span></label>
                 <div class="col-sm-6">
                  <input type="text" class="form-control" id="fname" name="fname" value="" aria-required="true" required="" data-msg-required="Please enter your firstname">

                  </div>
                 </div>
  <!-- File uplod code here -->


<div class="form-group">
                      <label class="col-md-3 control-label">Photo Upload</label>
                      <div class="col-md-6">
                      <div class="fileupload fileupload-new" data-provides="fileupload">
                      <div class="input-append">
                      <div class="uneditable-input">
                      <i class="fa fa-file fileupload-exists"></i>
                      <span class="fileupload-preview"></span>
                      </div>
                      <span class="btn btn-default btn-file">
                      <span class="fileupload-exists">Change</span>
                      <span class="fileupload-new">Select file</span>
                      <input type="file" id="photo" name="photo" value="" aria-required="true" required="" data-msg-required="Please select any photo">
                      </span>
                      <a href="#" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Remove</a>
                      </div>
                      </div>
                      </div>
                      </div>

1 个答案:

答案 0 :(得分:0)

请保持原样。

<input type="file" id="photo" name="photo" value="" aria-required="true" required data-msg-required="Please select any photo">

或者您也可以尝试类似

的内容
<input type="file" id="photo" name="photo" value="" aria-required="true" required="required" data-msg-required="Please select any photo">

两个选项都应该有效