1

I want to validate input type=file field using Angular.js. Here is my code:

<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Upload Image :</span>
<input type="file" class="filestyle form-control" data-size="lg" name="bannerimage" id="bannerimage" ngf-select ng-model="file" ngf-pattern="'image/*'" accept="image/*" ngf-max-size="20MB" ngf-min-height="100" ngf-resize="{width: 100, height: 100}" >
</div>

<input type="button" class="btn btn-success" ng-click="addProductInfoData();"  id="addProfileData" ng-value="buttonName"/>

I am using angular.js ngFileUpload module. My requirement is when user will forget to select image and click on Add button one alert message will notify user to select image. How can I do this?

7
  • How about if (form.file.$valid && $scope.file) ? Commented Dec 4, 2015 at 11:54
  • I will check and inform you. Commented Dec 4, 2015 at 11:55
  • No,Its not checking. Commented Dec 4, 2015 at 11:58
  • Have you make basic changes like name of the field and model name ? Commented Dec 4, 2015 at 12:00
  • What i did,I put console message like console.log('valid',billdata.bannerimage.$invalid); but it gave me false when file input is blank. Commented Dec 4, 2015 at 12:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.