图像验证不起作用 [英] Image validation not working
问题描述
我正在使用下面的图像验证指令
i am using directive for image validation like below
app.directive('validFile',function(){
return {
require:'ngModel',
link:function(scope,el,attrs,ngModel){
//change event is fired when file is selected
el.bind('change',function(){
scope.$apply(function(){
ngModel.$setViewValue(el.val());
ngModel.$render();
});
});
}
}
});
上传之前任何图像验证工作正常但是当我删除图像后单击提交按钮时,图像需要验证不起作用
before upload any image validation is working fine but when i click submit button after i removed image,image required validation is not working
我的查看页面代码如下所示
my view page code is like below
<div class="fileupload-new thumbnail" id="fileupload-new" style="width:175px; height:120px;" ng-show="!filmstrip.tmp_base_creative">
<img src="http://www.placehold.it/175x120/EFEFEF/AAAAAA&text=no+image" />
</div>
<div id="preview_image" class="fileupload-preview thumbnail base_creative" style="max-width: 200px; max-height: 150px; line-height: 20px;" ng-show="filmstrip.base_creative">
<img style="max-width: 200px; max-height: 150px;" src="<?php echo $this->config->item('creative_path');?>{{filmstrip.base_creative}}" />
</div>
<div>
<span class="btn btn-file">
<span class="fileupload-new" onclick="$('#base_creative').click()"><?php echo $this->lang->line('select_image');?></span>
<span class="fileupload-exists" onclick="$('#base_creative').click()">Change</span>
<input type="file" name="base_creative" id="base_creative" ng-model="filmstrip.base_creative" valid-file required required-message="'Creative is required'" onchange="angular.element(this).scope().getMobileImages(this.files,'base_creative',320,50);" />
</span>
<a ng-click="remove_image('tmp_base_creative',filmstrip.tmp_base1_creative)" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
我的尝试:
第一次当文件为空时如果我点击提交按钮它显示错误但是一旦上传图像并将其从临时文件夹中删除我没有得到验证错误如果我点击提交按钮即使它没有任何值
What I have tried:
first time when file is empty if i click submit button it shows error but once upload image and remove it from temporary folder i am not getting validation error if i click submit button even it does not have any value
推荐答案
apply(function(){
ngModel。
apply(function(){ ngModel.
setViewValue(el.val());
ngModel。
setViewValue(el.val()); ngModel.
render();
});
});
}
}
});
render(); }); }); } } });
上传之前任何图像验证工作正常但是当我删除图像后单击提交按钮时,图像需要验证不起作用
before upload any image validation is working fine but when i click submit button after i removed image,image required validation is not working
我的视图页面代码如下所示
my view page code is like below
<div class="fileupload-new thumbnail" id="fileupload-new" style="width:175px; height:120px;" ng-show="!filmstrip.tmp_base_creative">
<img src="http://www.placehold.it/175x120/EFEFEF/AAAAAA&text=no+image" />
</div>
<div id="preview_image" class="fileupload-preview thumbnail base_creative" style="max-width: 200px; max-height: 150px; line-height: 20px;" ng-show="filmstrip.base_creative">
<img style="max-width: 200px; max-height: 150px;" src="<?php echo
这篇关于图像验证不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!