So I'm writing a custom validator and I need to check if a
file has been uploaded using the asp.net File Upload Control.
So far I have:
function validate(sender, args)
{
if ($('#<%=hdnID.ClientID%>').val() != "False")
{
args.IsValid =true;
}
else
{
if ($('#<%=fup.ClientID %>').val() != '' )
{
alert("Run some code here");
}
else
{ }
}
}
The bit that is not right is
if ($('#<%= fup.ClientID %>').val() != '' )
I'm not sure how to determine whether the control has a file
or not. Any suggestions would be awesome. Thanks.
Anonymous User
19-Jan-2015This might not be the JQuery-est way of doing it, but I've had success with something like this:
I also usually check that uploader != null before checking the value. Hope that helps!