-
Notifications
You must be signed in to change notification settings - Fork 1.1k
File Size validation #73
Comments
Make sure the file inputs are in separate Also, you should probably guard against if ($el[0].files[0] && $el[0].files[0].size > fileSizeMax) {} I threw this into a JSBin and it seems to be working. |
Thank You |
Hi, I am not able to validate my single file field. I have followed your code in JSBin however the validation happens only once when I click the field to select file. It shows file is required "Please select a file." and "Max 5MB". HTML
Validator.js
|
@abhiagrawal87 that example is from an old version of the validator. here's an updated example |
Thanks for your prompt response. Your example is working for a standalone system however when I try to get the same result from a ajax driven form fields then it is not working. |
Hi, can you help me out with file size validation on Ajax form? I tried several options.. created separate file to test the functionality with Ajax but somehow validation after file selection is not working. Validations on all other fields are working seamlessly. Infact when I remove the file, then validation for "File is required" appears. |
I'm not sure what you are trying to do with ajax. |
@1000hz I can show you a working link. Can I have your email id? What I am trying to achieve is:
Issue: I have defined a max file size to be 5mb and would like to validate before form is submitted. This validation is not happening. Might be it has to do something with Ajax. Thanks |
you need to initialize the validator via JS with |
@1000hz lots of tweaking and it finally worked for me. Thanks a lot 👍 |
i want the file input only the image formats. how to do it |
@abhilashrajrs
|
JS:
HTML:
it is working but only with one input[type=file], when i have 2 input[type=file] even with error i can click submit and go to next page.
So I added to JS something like that:
But it isn't best solution.
Any ideas how fix it?
The text was updated successfully, but these errors were encountered: