0

here's a simple custom validator in angular 2

hasUpperCase(control:FormControl):{[s:string]:boolean}{
    if (/[A-Z]/.test(control.value) === true { return null }
    else{ return {noUpperCase:true} }
}

How can I access the else return, so that I can prompt the user that the input has no upper case?

Thanks!

1 Answer 1

1

Get a reference to the form (I can't see from your code how you use forms or what version) (or get a reference to the control directly), look up the control the validator is applied to read it's errors property. It contains all the error objects returned by all failed validators.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.