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: ''
})
}
}
);
File input size validation is a crucial step in ensuring that users upload files within the allowed size limits, preventing performance issues and security risks. By setting maximum file size restrictions in web forms or applications, developers can enhance user experience and system efficiency. Implementing client-side and server-side validation helps avoid unnecessary uploads and reduces server load. Platforms like apkek games also utilize such validations to ensure smooth gameplay experiences by restricting oversized game files, optimizing downloads, and maintaining performance across different devices.
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