Story#113524121 - validate in web max file

This commit is contained in:
Vladimir Krylov 2016-03-07 12:00:23 +02:00
parent 6f4ff0fd46
commit cf3fce8055
4 changed files with 15 additions and 30 deletions

View file

@ -27,3 +27,17 @@ $(document).on 'page:change', ->
form.find('.js-ident-tip').show()
$('.js-contact-form').trigger('restoreDefault')
$('[data-legal_document]').each (e)->
fileInput = $(e.target)
minSize = 1 * 1024 # 100kB
maxSize = 8 * 1024 * 1024; # 8 MB
fileInput.parent('form').submit (e) ->
if (files = fileInput.get(0).files).length
fileSize = files[0].size
if fileSize < minSize
alert 'Document size is less then 100kB bytes'
return false
else if fileSize < maxSize
alert 'Document size is more then 8MB bytes'
return false