Search code examples
asp.net-mvcasp.net-mvc-4remote-validation

How to suppress asp.net mvc remote validation until all fields provided on form?


I have a model which has following properties:

public class AddAdsItemViewModel
    {
        [Remote("AdsItemExist", "AdsItem", "Administrator", ErrorMessage = "Already Exists.", HttpMethod = "POST", AdditionalFields = "AdsTypeId, AdsSizeId, PublishTypeId, OsTypeId, DeviceTypeId")]
        public string Name { get; set; }

        public int AdsTypeId { get; set; }

        public int AdsSizeId { get; set; }

        public int PublishTypeId { get; set; }

        public int OsTypeId { get; set; }

        public int DeviceTypeId { get; set; }
    }

My problem is that when I fill the textbox for Name property and the textbox lost focus, the remote validation is called, and other properties will be null !!

This is because the other fields on the form still are not filled and I want to suppress the remote call validation until all of the properties provided on the form.

Is there any solution for this problem ?


Solution

  • Update:

    I found the solution over the following link:

    Multiple fields validation using Remote Validation