0
     public string InsuredName
              {
                  get;
                  set;
              }
  public string Card_No
          {
              get { return this.card_No; }
              set { this.card_No = value; }
          }

here i have two properites, CardNo will be required only for some InsuredNames.when User types InsuredName then i want to go to database and check wheather it has Card_No validation if yes then i want to validate it as required other wise not, i tried remote validation but it is not working

Nighil
  • 4,099
  • 7
  • 30
  • 56
  • possible duplicate of [RequiredIf Conditional Validation Attribute](http://stackoverflow.com/questions/7390902/requiredif-conditional-validation-attribute) – Rafay Oct 24 '12 at 06:15
  • each time user types name and loses focus then validation check must be done in server is this possible with RequiredIf – Nighil Oct 24 '12 at 06:17
  • i think you should use java script validation . when use type InsuredNames in InsuredNames text box then you use jquery blur event and check your card no in your database if yes then you show your java script message i think this will help you . – Rajpurohit Oct 24 '12 at 06:18
  • but the problem is doesn't want to submit the form if validation fails and there is specific format for all validation – Nighil Oct 24 '12 at 06:22

1 Answers1

0
private string insuredName;
  private bool cardNoRequiresValidation;
  public string InsuredName
              {
                  get {return insuredName;}
                  set { cardNoRequiresValidation = DoesCardNoRequiresValidation(Value); insuredName = value;}
              }
  public string Card_No
          {
              get { return this.card_No; }
              set { cardNoRequiresValidation ? ValidateCardNo(value) : card_No =  value; }
          }
  private bool DoesCardNoRequiresValidation(string insuredName)
  { //if requires validation 
    // return true;
    //else 
    //return false;
  }
  private void ValidateCardNo(string cardNo)
  {
    //execute validation logic
  }
awright18
  • 2,255
  • 2
  • 23
  • 22