web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Validating Date Text F...
Power Apps
Answered

Validating Date Text Field

(0) ShareShare
ReportReport
Posted on by 14

Good afternoon,

I want to validate a date column that is of format, single line of text, in the following way, YYYY-MM-DD.

I am using =IsMatch(Date.Text, "\d{4}-\d{2}-\d{2}") where it says validation when I go into edit column in microsoft lists so that it has the same validation in power apps. Every time I save it and then I go back to see it, it's no longer there so I am assuming I am writing something wrong. I also want to know if my assumption that the validation will carry over in power apps is true or I have to include it in power apps directly.

Any suggestions?

Categories:
I have the same question (0)
  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @pchristou,

    Could you please tell me that how you validate in your PowerApps app or validate in your list?

    Do you want to validate the date input before you save it?

    I think you should validate it in your Power Apps app.

    I have a simple test for you, please take a try as below.

    1). Add a TextInput for date input

    2). Set the OnChange property of the TextInput as below:

    If(
     !IsMatch(
     TextInput_Date.Text,
     "\d{4}-\d{2}-\d{2}"
     ),
     Notify(
     "Please input date in YYYY-MM-DD format!",
     NotificationType.Error
     )
    )

    3). If you want to save it to your list, please add a button and set the OnSelect as below:

    If(
     !IsMatch(
     TextInput_Date.Text,
     "\d{4}-\d{2}-\d{2}"
     ),
     Notify(
     "Please input date in YYYY-MM-DD format!",
     NotificationType.Error
     ,
     Patch(
     YourList,
     Defaults(YourList),
     {
     Date: TextInput_Date.Text
     }
     )
    )

     

  • kdavies1966 Profile Picture
    on at

    Hi @pchristou 

    I added a check to see if the entered date was valid, as well as matching the format of a date with the below code (In the BorderColor attribute of the TextInput). It basically checks to make sure that DateValue hasn't incremented the month based on the number of days entered.

    If(!IsBlank(Self.Text) && !IsMatch(Self.Text, "\d{2}/\d{2}/\d{4}"), Red,
    !IsBlank(Self.Text) && Text(DateValue(Self.Text), "dd/mm/yyyy") <> Self.Text, Red,

    RGBA(0, 18, 107, 1))

    The same logic can apply in a Patch statement or other attribute as you wish.

    Best Regards,
    Keith




  • Nikilp Profile Picture
    19 on at

    Hi, 

    I have created a new power app.
    In the application one of the text input field users will update date and time values
    Ex format: 29/Dec/22 10:30 AM

    Before saving the data I need to validate the format like (DD/MMM/YY HH:MM AM/PM).

    Could you please help if the user entered the wrong format need to through an error message or highlight the field.

    In my form needs to update multiple dates and time fields in a single field, and users will copy and paste the details, hence we used the CARD "TEXT INPUT".

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard