Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Required attribute? #422

Closed
devmark opened this issue Nov 28, 2014 · 19 comments
Closed

support Required attribute? #422

devmark opened this issue Nov 28, 2014 · 19 comments

Comments

@devmark
Copy link

devmark commented Nov 28, 2014

this package support Required attribute?

http://stackoverflow.com/questions/16207202/required-attribute-not-working-with-file-input-in-angular-js

@danialfarid
Copy link
Owner

It is supported in version 2.0.0. See the demo page

@piotrkulpinski
Copy link

Could you tell me how to pass the required attribute to generated file input when you're using it on "div" element like that:

<div ng-file-select ng-model="myFiles" required>(...)</div>

It looks like the required attr is not passed to generated input.

@danialfarid
Copy link
Owner

ng-required read the docs.

@piotrkulpinski
Copy link

I did and didn't saw anything helpful. Do you have any example of using that with div ng-file-input?

@danialfarid
Copy link
Owner

Demo page has the example.

@antonioreyna
Copy link

I? cant find the example either

@danialfarid
Copy link
Owner

The first form in the demo page has required. https://angular-file-upload.appspot.com/

@antonioreyna
Copy link

and could it have that same required attribute in the drop zone?

@danialfarid
Copy link
Owner

yes

@antonioreyna
Copy link

I tried and it is not working

<div ng-file-drop ng-file-select ng-model="image" class="drop-box" drag-over-class="{accept:'dragover', reject:'dragover-error', delay:100}" ng-multiple="false" allow-dir="false" ng-accept="'image/*'" ng-file-change="fileDropped($files, $event, $rejectedFiles)" required>Drop your image</div>

@danialfarid
Copy link
Owner

        <div required="" name="drop" ngf-drop="" ngf-select="" ng-model="files">
            Drop files  
         </div>
    <i ng-show="myForm.drop.$error.required">*required</i>

if you still cannot figure it out create a jsfiddle.

@bmsdave
Copy link

bmsdave commented Jan 11, 2017

@danialfarid, Hi!

wath this example http://jsfiddle.net/bmsdave/3v8e4h7u/2/

if I select some files, and clear all -> picFile = [] , and require dont work.

sorry, for my english =\

@bmsdave
Copy link

bmsdave commented Jan 11, 2017

@danialfarid,

this error exist if set: multiple="true" of ngf-multiple="true"

@danialfarid
Copy link
Owner

set picFile = null

@bmsdave
Copy link

bmsdave commented Jan 13, 2017

@danialfarid, where I must set picFile = null?
If i set in controller MyCtrl ( see example in jsfiddle ), picFile rewrite on [] again if i dont choised any files.

And thx for fast answer! =)

@danialfarid
Copy link
Owner

If you set picFile = null it would clear the errors.

@bmsdave
Copy link

bmsdave commented Jan 19, 2017

@danialfarid, i set $scope.picFile = null in controller.
It is dont work: http://jsfiddle.net/3v8e4h7u/3/
err

@danialfarid
Copy link
Owner

What doesn't work? Provide steps to reproduce and expected/actual result.

@bmsdave
Copy link

bmsdave commented Apr 3, 2017

@danialfarid, http://jsfiddle.net/3v8e4h7u/3/
steps:

  1. choise some files
  2. clear input (click on input and click cancel button)
  3. see the screenshot in comment on 19 Jan. picFile will be equal array, and require won't work.

pull request #1833 fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants