title: Special character validation
body: <p>I have some javascript written to validate that a string is alphanumeric but i was just wondering how i could add some code to include hyphens(-) and slash's(/) as acceptable inputs. Here is my current code:</p>
  
  <pre><code>function validateAddress() {
    var address = document.getElementById('address');
  
    if (address.value == "") {
      alert("Address must be filled out");
      return false;
    } else if (document.getElementById('address').value.length &gt; 150) {
      alert("Address cannot be more than 150 characters");
      return false;
    } else if (/[^a-zA-Z0-9\-\/]/.test(address)) {
      alert('Address can only contain alphanumeric characters, hyphens(-) and back slashs(\)');
      return false;
    }
  }
  </code></pre>