title: How to check if an input contains only upper and lowercase letters, numbers, and dashes by onclick event?
body: <p>How to check in this form if input contains only upper and lowercase letters, numbers, and dashes by onclick event?</p>
  
  <pre><code>&lt;form id="domaincheck" class="form-inline ltr" method="post"&gt;
      &lt;input type="text" class="form-control center input-md" name="sld" id="sld" placeholder="pleade enter domain name" required&gt;
      &lt;select class="form-control ltr input-md input-group-addon" id="tld" name="tld" multiple="multiple"&gt;
          &lt;option value="com" selected=""&gt;.com&lt;/option&gt;
          &lt;option value="net"&gt;.net&lt;/option&gt;
          &lt;option value="org"&gt;.org&lt;/option&gt;
      &lt;/select&gt;
      &lt;button type="button" class="btn btn-info" onclick="get_whois()"&gt;check!&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
  function get_whois(){
      var sld = $('#sld').val();
      if (sld.length == 0) {
          alert('plase enter domain name!');
          return false;
      }
      if (sld.length &lt;= 3) {
          alert('at least 4 chars');
          return false;
      } else {
          //do something
      }
  }
  &lt;script&gt;
  </code></pre>