title: How to get id of model property for use with a custom IClientValidatable in MVC3
body: <p>I am trying to write a custom validation attribute that will conditionally require fields based on boolean properties of the model. </p>
  
  <p>I have my attribute implementing IClientValidatable. I have the name of the property to check, but I dont know how to get the client id of the target property.</p>
  
  <pre><code>public IEnumerable&lt;ModelClientValidationRule&gt; 
                          GetClientValidationRules(ModelMetadata metadata, 
                                                   ControllerContext context)
  {
      var clientTarget = ?????;
      var rule = new ModelClientValidationRule()
      {
          ErrorMessage = 
              FormatErrorMessage(metadata.DisplayName ?? metadata.PropertyName),
          ValidationType = "requiredif"
      };
  
      rule.ValidationParameters["target"] = clientTarget;
  
      yield return rule;
  }
  </code></pre>
  
  <p>The javascript:</p>
  
  <pre><code>$.validator.addMethod("requiredif", function (value, element, target)
  {
      //check on value of target
  });
  
  $.validator.unobtrusive.adapters.addSingleVal("requiredif", "target");
  </code></pre>
  
  <p>How can I get the client id of the target property so that the client side javascript can check on the value?</p>