【问题标题】:jquery validation engine for file upload validation when i used jasny bootstrap file upload当我使用 jasny bootstrap 文件上传时,用于文件上传验证的 jquery 验证引擎
【发布时间】:2013-04-22 07:44:10
【问题描述】:

我正在使用 pos-absolute 的 jQuery 验证引擎插件。

我有一个插件可以隐藏输入 type="file" 并用按钮替换它。

这工作正常,如果没有选择文件然后jquery验证引擎不显示弹出消息,它是提交成功。

我遇到的问题是当字段为空时不显示弹出窗口并且不验证文件上传字段。

这是我的硬编码html:

<div class="fileupload fileupload-new" data-provides="fileupload" id="question_choice_image" style="display:none;">
<div class="fileupload-preview thumbnail"   id="question_choice_image" style="width: 70px; height: 30px;"></div>
<div >
<span class="btn btn-file"><span class="fileupload-new">Select image</span><span class="fileupload-exists">Change</span><input type="file" data-validation-engine="validate[required]"  data-errormessage-value-missing="Question is required!"  name="question_choice_img" /></span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>

所以结构就在那里,所以我可以验证文件上传文件。

【问题讨论】:

    标签: javascript jquery jquery-plugins jquery-file-upload jquery-validation-engine


    【解决方案1】:

    而不是用“display:none;”来隐藏它 尝试使其可见,但将其边距移至:-9999px .... 我的解决方案是: 我将它设置为绝对和高度:0px;宽度:0px;行高:0px;字体大小:0px; 并将其放置在父容器的左上角,我会收到所有警报;)

    诀窍是不要“隐藏”原始输入字段,因为警报不会在显示时触发:无字段...希望对您有所帮助....

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-05
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多