title: How to validate a field only contains alphanumerics, spaces, dashes & always contains at least one alpha or numeric character?
body: <p>I have an input field that I need to add validation to in c#. The field should only allow alphanumerics, spaces, dashes, and must contain at least one alpha or numeric character. I have the layout of the function, but I am not sure how to formulate the conditions for the if statement.</p>
  <pre><code>//function call
   ValidateSchoolIDField(request.SchoolID, &quot;School ID&quot;, validationErrors);
  
  //function
  private static void ValidateSchoolIDField(string value, string fieldname, List&lt;ValidationError&gt; validationErrors)
  {
       if (request.SchoolID != alphanumeric/space/dash) 
          validationErrors.Add(new ValidationError(&quot;ivalid input for &quot; + fieldName)):
  } 
  </code></pre>