JS - Regex for one letter and 6 numbers
<p>I have this regular expression to test if an input starts with the letter "a" and is followed by 6 numbers. On the online validator seems to work, but on JavaScript doesnt.</p>

<p>This is the code: </p>

<pre><code>function checkBookingReference (ref) {
    var regex = /(^a|A)([0-9]{6})/;
    return regex.test(ref);
}
</code></pre>

<p>The function returns true if I enter more than six numbers, and it shouldn't. Any idea why?</p>