You are missing closing dollar at the end. Correct one is: /^.{6,7}$/
/^.{6,7}$/
Match the start and the end.
var sixCharsRegEx = /^.{6,7}$/;
Your improved example
you must use end of string symbol $
$
like this ^.{6,7}$
^.{6,7}$