Criteria:
1 - I want to ensure users are entering the phone number as (333) 333-3333.
2 - If the phone number is incorrect, I want to change the COLOR and FILL values and I want to make the Clear_Phone button VISIBLE.
3 - I don't want to see these changes as the user is entering the number, it should change after the last digit is entered and/or the field loses focus.
I'm using OnChange here for the first time. It seems to be working but I'm not sure if the web designer / my mouse cursor is reflecting the real-world mobile app.
I think this code (below) for the text input is working but is there a more efficient way to do this? Can I set all this code in one place and tell the elements (fill, color, visible) what to do?
My main question:
I'm having issues with setting VISIBLE for Clear_Phone. I'm not sure where to place this value or if I should be setting a variable or what.
I've tried 'if FILL is red and ONCHANGE is true, then Visible=true' but that's not working. It's always visible after one character is entered into the text field. I've tried setting a variable within an ISMATCH else statement but that's not resolving.
TEXT INPUT: ContactPhone
//ONCHANGE
Set (varContactPhone,true)
//FILL COLOR
If(varContactPhone,
If(IsBlank
(ContactPhone.Text),RGBA(252, 251, 237, 1),
IsMatch
(ContactPhone.Text, Match.LeftParen & Match.Digit & Match.Digit & Match.Digit & Match.RightParen & Match.Space & Match.Digit & Match.Digit & Match.Digit & Match.Hyphen & Match.Digit & Match.Digit & Match.Digit & Match.Digit),
RGBA(252, 251, 237, 1),
Color.Red)
,RGBA(252, 251, 237, 1))
//TEXT COLOR
If(varContactPhone,
If(IsBlank
(ContactPhone.Text),Color.Black,
IsMatch
(ContactPhone.Text, Match.LeftParen & Match.Digit & Match.Digit & Match.Digit & Match.RightParen & Match.Space & Match.Digit & Match.Digit & Match.Digit & Match.Hyphen & Match.Digit & Match.Digit & Match.Digit & Match.Digit),
Color.Black,
Color.Yellow)
,Color.Black)