Dear @nauna,
Please refer below example , it might help you
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
<br />
<asp:RequiredFieldValidator ErrorMessage="Required" ControlToValidate="FileUpload1" runat="server" Display="Dynamic" ForeColor="Red" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="(.*?)\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF)$" ControlToValidate="FileUpload1" runat="server" ForeColor="Red" ErrorMessage="Please select a valid image file." Display="Dynamic" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ForeColor="Red" ErrorMessage="CustomValidator" ControlToValidate="FileUpload1" ClientValidationFunction="ValidateFileLimit"></asp:CustomValidator>
<br />
<asp:Button Text="Submit" runat="server" />
<script type="text/javascript">
function ValidateFileLimit(sender, args) {
var fileCount = document.getElementById('FileUpload1').files.length;
if (fileCount > 3) // Selected images with in 3 count
{
alert("Please select only 3 images..!!!");
return false;
}
else if (fileCount <= 0) // Selected atleast 1 image check
{
alert("Please select atleat 1 image..!!!");
return false;
}
return true; // Good to go
}
</script>