Skip to content

Instantly share code, notes, and snippets.

View acmartinsalmeida's full-sized avatar
🍊

Alice acmartinsalmeida

🍊
View GitHub Profile
@acmartinsalmeida
acmartinsalmeida / gist:03252d11eb03a9448c4d
Last active December 3, 2015 16:09
Validator for input type file in Parsley 2.x
window.Parsley
.addValidator('filemaxsize', {
requirementType: 'string',
validateString: function (val, req){
var reqs = req.split('|');
var input = $('input[type="file"][name="'+reqs[0]+'"]');
console.log(reqs[0], reqs[1]);
var maxsize = reqs[1];
var max_bytes = maxsize * 1000000, file = input.prop('files')[0];
return file.size <= max_bytes;
### Keybase proof
I hereby claim:
* I am acmartinsalmeida on github.
* I am acmartinsalmeida (https://keybase.io/acmartinsalmeida) on keybase.
* I have a public key ASBBsu27B9x1ysIZyhxz0eL2mfM5lu86gFMYR4xMZlopcAo
To claim this, I am signing this object: