Regex for Validetta jQuery plugin
<p>I am validating an input field with the Validetta jQuery plugin (<a href="http://lab.hasanaydogdu.com/validetta/demo/basics.html" rel="nofollow">regex demo</a>). </p>

<p>I want to allow numbers, letter, spaces and dashes.  </p>

<p>I'm trying to create the correct regex for the Validetta parameters:</p>

<pre><code>validators: {
regExp: {
regname : {
pattern : [pattern here]
errorMessage : 'Only numbers, letters, spaces and dashes allowed'
}
}
}
</code></pre>

<p>Here is a link to a regex tester with prefilled regex and results:</p>

<p><a href="http://regexr.com/3e10d" rel="nofollow">http://regexr.com/3e10d</a></p>

<p>It seems to be matching everything I want it to match.  </p>

<p>It provides the regex in three formats:</p>

<p>Expression:  <code>/([A-Z0-9 -])/ig</code></p>

<p>Pattern:  <code>([A-Z0-9 -])</code></p>

<p>Javascript:  <code>text.match(/([A-Z0-9 -])/ig);</code></p>

<p>These are not having the desired effect when used in Validetta, eg:</p>

<pre><code>pattern : /([A-Z0-9 -])/ig,
</code></pre>

<p>This validates:  <code>web's test</code><br>
This doesn't:  <code>'web</code></p>

<p><strong>OR:</strong></p>

<pre><code>pattern : ([A-Z0-9 -]),  
</code></pre>

<p>Causes page not to load with Firebug error:</p>

<blockquote>
  <p>// SyntaxError: expected expression, got ']'</p>
</blockquote>

<p>What pattern should I be using in Validetta to get the desired results?  </p>