# Required Field Validation

> caution  **RadUpload** has been replaced by [RadAsyncUpload](https://demos.telerik.com/aspnet-ajax/asyncupload/examples/overview/defaultcs.aspx), Telerik’s next-generation ASP.NET upload component. If you are considering Telerik’s Upload control for new development, check out the [documentation of RadAsyncUpload ](https://www.telerik.com/products/aspnet-ajax/documentation/controls/asyncupload/overview) or the [control’s product page](https://www.telerik.com/products/aspnet-ajax/asyncupload.aspx). If you are already using **RadUpload** in your projects, you may be interested in reading how easy the transition to RadAsyncUpload is and how you can benefit from it [in this article](https://www.telerik.com/products/aspnet-ajax/documentation/controls/asyncupload/migrating-from-radupload-for-asp.net-ajax-to-radasyncupload). The official support for **RadUpload** has been discontinued in June 2013 (Q2’13), although it is still be available in the suite. We deeply believe that **RadAsyncUpload** can better serve your upload needs and we kindly ask you to transition to it to make sure you take advantage of its support and the new features we constantly add to it.

Sometimes you might want to implement required field validation against the RadUpload control. That is to ensure that at least one file is uploaded on the server.

To accomplish this, we will use a custom validator.

```ASPNET
<telerik:radupload id="RadUpload1" initialfileinputscount="3" allowedfileextensions=".txt"
    targetfolder="~/uploads" runat="server"></telerik:radupload>
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validateRadUpload"
    ErrorMessage="Please select at least one Text file" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
```

Here is the client validation function of the validator:

```JavaScript
	
function validateRadUpload(source, e) { 
    e.IsValid = false;      
    var upload = $find("<%= RadUpload1.ClientID %>");   
    var inputs = upload.getFileInputs();   
    for (var i = 0; i < inputs.length; i++)    {
        //check for empty string or invalid extension     
        if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) {
            e.IsValid = true;
            break;
        }
    }
}  
				
```

Here is the server validation function of the validator:

```C#
	
private void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs e)
{
    е.IsValid = (RadUpload1.InvalidFiles.Count == 0);
} 		

```

```VB.NET
	     
Private Sub CustomValidator1_ServerValidate( _
     ByVal source As Object, _
     ByVal e As ServerValidateEventArgs) _
     Handles Customvalidator1.ServerValidate
    е.IsValid = (RadUpload1.InvalidFiles.Count = 0)
End Sub
		
```

## See Also

* [Integrated Validation](https://www.telerik.com/products/aspnet-ajax/documentation/controls/upload/validation/integrated-validation)

* [Custom Validation](https://www.telerik.com/products/aspnet-ajax/documentation/controls/upload/validation/custom-validation)

* [Client-side Validation](https://www.telerik.com/products/aspnet-ajax/documentation/controls/upload/validation/client-side-validation)
