JSFiddle - React, Tailwind, and code Playground
by Dedi Wibisono
HTML
<input type="file" id="one" class="input">
<input type="file" id="two" class="input">
<button>click</button>
JavaScript
$('button').click (function(){
var size=1024 * 1024;
if($("#one").val() != "") {
var file_size=document.getElementById('one').files[0].size;
if(file_size>=size) {
alert('image one too large')
return false
}
}
if($("#two").val() != "") {
var file_size_2=document.getElementById('two').files[0].size;
if(file_size_2>=size) {
alert('image one two large')
return false
}
}
alert('success without image')
})