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

Notifications

Announcements

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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard