Skip to main content

Practice ยท 1 of 3

Field Validator

Write validateField(name, value) that RETURNS null when valid or an error-message string when not: - name โ€” required, 2โ€“40 characters after trim - email โ€” must contain @ with non-empty parts on both sides - age โ€” a number 16โ€“120 inclusive (accept numeric strings) Any other field name returns null.

Difficulty: intermediate

Back to lesson: Practice: Advanced Forms โ€” Practice