File input size validation
Hi
I used the link below for file validation.
https://preview.keenthemes.com/html/keen/docs/forms/formvalidation/advanced
How can I check the size of the input file as well?
var validator = FormValidation.formValidation(
form,
{
fields: {
'avatar': {
validators: {
notEmpty: {
message: 'Please select an image'
},
file: {
extension: 'jpg,jpeg,png',
type: 'image/jpeg,image/png',
message: 'The selected file is not valid'
},
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
Replies (2)
I changed it to
file: {
extension: 'jpg,jpeg,png',
type: 'image/jpeg,image/png',
maxSize:20000,
minSize:200,
message: 'The selected file is not valid'
}
and it worked.
Hi
,
Glad to know that you figured it out! All the best with your projects!
Regards,
Sean