Jason Phang
Well-known member
- Joined
- Aug 13, 2019
- Messages
- 46
- Programming Experience
- Beginner
I am using sweet alert alongside c# asp.net. For my download and delete button, the sweet alert display managed to be displayed when the user clicked the button. For the upload button, i wanted that the code will check if the file uploaded by the user was empty or not. If it was empty, then a message ("No file uploaded") and if it was not empty ('File was uploaded successfully").
However, when i click on the upload button, neither of these pop-up messages are displayed. What am I missing out?
Upload Button:
<div style="width:80%; text-align:left;">
@using (Html.BeginForm("UploadFile", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<p>
<label for="file">Upload file:</label>
<input type="file" name="file" id="file" />
<input type= "submit" value="Upload" id= "fileUpload"/>
<script>
$('#fileUpload').click(function (e) {
if ($('#fileUpload').val() === "") {
sweetAlert("No file uploaded");
}
if ($('#fileUpload').val() !== ""){
sweetAlert("File Uploaded Succesfully");
}
});
</script>
</p>
}
</div>
However, when i click on the upload button, neither of these pop-up messages are displayed. What am I missing out?