I took a function here from the Internet to try to validate my 'file' field, which will be for the client to send photos, I want the client can not leave the 'file' field empty, without uploading any, and I want it to be of at most 300mb, and that is in the format either 'jpeg' or 'jpg' or 'png'. I just got a code to validate if it is bigger than 300MB, I just do not know if it's totally right, this:
function validafoto() {
var upload = document.cad.getElementById("upload");
var size = upload.files[0].size;
if(size > 3145728) { //3MB
alert('Não permitido'); //Acima do limite
return false;
}
And now I do not know how to call it in my form, I tried on my function validate form, but it did not work very well, could they help? I'll leave the entire code on my form here: link