I have a form in Angular with a text input field that requires the entry of lowercase letters separated by commas, like this: c, d, e, g, a, f etc...
Currently, the submit button activates as soon as any part of the input matches the required format, allowing users to submit the form even if they include numbers or capital letters. I want to prevent this and only allow submission when the input matches the specified format exactly, rather than just partially matching. The regex should restrict input to lowercase letters that match one of the 6 options listed above and are separated by commas.
Input text field:
<input type="text" name="input" ng-model="keysToPlay.text" ng-pattern="format" required ng-trim="false" class="form-control" placeholder="c, d, e, etc...">
My regex pattern is:
$scope.format = /^[cdefgab]{1}(, [cdefgab]{1})*/;