i have 3 input file, i wanna make a javascript validation for 3 input file in one submit button form event onSubmit=""
<form action="step2_crud_dev.php" method="post" enctype="multipart/form-data" class="form-horizontal" role="form" id="dataPribadi" >
<div>
<input type="file" name="fUpload1" id="fileUpload1"/>
<input type="file" name="fUpload2" id="fileUpload2"/>
<input type="file" name="fUpload3" id="fileUpload3"/>
</div>
<div>
<input type="submit" name="upload" value="upload" />
</div>
</form>
EDITED CODE new code that working but, still proccess saving
$(document).ready(function(){
$('#tbl_next').click(function(){
//alert('hello');
$('input[type="file"]').each(function(){
var thisFile = $(this);
var fileSize = thisFile[0].files[0].size;
var fileType = thisFile[0].files[0].type;
//alert(fileSize);
if(fileSize>1048576){ //do something if file size more than 1 mb (1048576)
alert(fileSize +" bites\n ukuran gambar terlalu besar");
return false;
}else{
switch(fileType){
case 'image/png':
case 'image/gif':
case 'image/jpeg':
case 'image/pjpeg':
alert("Acceptable image file!");
break;
default:
alert('Unsupported File!');
return false;
}
}
});
$('form#dataPribadi').submit();
});
});