Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
        });
      });
    }
  }
});

Quote:
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900