Bird
0
0

How would you fix this FormControl to require at least 3 letters only, ignoring digits?

hard🚀 Application Q9 of 15
Angular - Reactive Forms
How would you fix this FormControl to require at least 3 letters only, ignoring digits?
new FormControl('ab1', [Validators.minLength(3), Validators.pattern('^[a-z]+$')]);
AChange pattern to '^[a-z0-9]+$'
BRemove Validators.pattern
CRemove Validators.minLength
DChange input to 'abc' or remove digits
Step-by-Step Solution
Solution:
  1. Step 1: Understand pattern validator

    Pattern '^[a-z]+$' allows only letters, so digits cause invalid.
  2. Step 2: Fix input to match pattern

    Input 'ab1' contains digit '1', so change input to letters only like 'abc'.
  3. Final Answer:

    Change input to 'abc' or remove digits -> Option D
  4. Quick Check:

    Input must match pattern to be valid [OK]
Quick Trick: Input must match pattern regex exactly [OK]
Common Mistakes:
MISTAKES
  • Changing pattern to allow digits
  • Removing needed validators
  • Ignoring input mismatch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes