Help with jquery validation fileupload
Hi all Masters,
I have a FileUpload function in asp.net.
Below is my asp.net button.
- <asp:FileUpload id="FileUpload1" runat="server" Width="150px"/>
- <asp:Button id="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
Which I can upload successful.
I try with asp validator but no luck.
- <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
- runat="server" ErrorMessage="Please upload your receipt."
- ControlToValidate="FileUpload1" CssClass="alerttext"></asp:RequiredFieldValidator>
I need to validate whether if it's empty. If it's empty then alert user.
I have a img type button. The code are below.
- <img name="Submit" type="image" onMouseOver="this.src='images/B_F_H.gif'" onMouseOut="this.src='images/B_F_L.gif'" onClick="validateField();" src="images/B_F_L.gif" width="105" height="32"/>
What I want to do is when clicked on this I need to validate the fileupload is not empty.
Below code I tried but no respond.
- <script type="text/javascript">
- function validateField()
- {
- var imgVal = $('#FileUpload1').val();
- if(imgVal=='')
- {
- alert("empty input file");
- }
- return false;
- };
- </script>