Hi nauna,
Please refer below sample.
HTML
<input id="FileUpload1" onchange="Validate()" type="file" multiple="multiple" />
<script type="text/javascript">
function Validate() {
var fileCount = document.getElementById("FileUpload1").files.length;
if (fileCount > 4) {
alert("max 3 images allowed.");
document.getElementById("FileUpload1").value = null;
}
}
</script>
Demo