cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LyonsBI_BRL
Resolver II
Resolver II

Validation Error for Field

Looking to run some validation where the user must enter something like "A-1234"

Coalesce(
    Parent.Error,
    If(
        !IsBlank(DataCardValue33.Text) &&
        !IsMatch(DataCardValue33.Text,Match.MultipleLetters) &&
        !IsMatch(DataCardValue33.Text,Match.OptionalDigits),
        "Enter Bound Book #"
    ),
    If(
        !IsBlank(DataCardValue33.Text) &&
        Len(DataCardValue33.Text) <> 5,
        "Example A-1234")
)

 

However no matter what I've tried I can't get the error message to go away when I've entered the letter, hyphen and number. I'm sure I'm missing something simple here to get this to work correctly. Any help would be greatly appreciated. 

 

Thanks!

LyonsBI_BRL_0-1647236081787.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
iAm_ManCat
Super User
Super User

Hello - you could use Regex validation for this one:

 

If(
   IsMatch(DataCardValue33.Text, "([A-Z][-])([0-9]{4})"),
   "Valid Match"
   "Invalid match, try A-1234 for example"
)

 

I was unsure if it had to be exactly 4 numbers from your example, but if you want to match between 1 and 4 numbers you could use:

 

If(
   IsMatch(DataCardValue33.Text, "([A-Z][-])([0-9]{1,4})"),
   "Valid Match"
   "Invalid match, try A-1234 for example"
)

 

Could you give that a try and let me know how you get on?

 

Cheers,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

3 REPLIES 3
iAm_ManCat
Super User
Super User

Hello - you could use Regex validation for this one:

 

If(
   IsMatch(DataCardValue33.Text, "([A-Z][-])([0-9]{4})"),
   "Valid Match"
   "Invalid match, try A-1234 for example"
)

 

I was unsure if it had to be exactly 4 numbers from your example, but if you want to match between 1 and 4 numbers you could use:

 

If(
   IsMatch(DataCardValue33.Text, "([A-Z][-])([0-9]{1,4})"),
   "Valid Match"
   "Invalid match, try A-1234 for example"
)

 

Could you give that a try and let me know how you get on?

 

Cheers,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


@iAm_ManCat 

 

You read my mind on that one! Thanks' that worked perfectly! 😀

 

If(
   IsMatch(DataCardValue33.Text, "([A-Z][-])([0-9]{1,4})"),
   "Valid Match"
   "Invalid match, try A-1234 for example"
)

 

 

Excellent, glad I could help 🙂

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,404)