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 / provide message when u...
Power Apps
Unanswered

provide message when user enters 2 digit year

(0) ShareShare
ReportReport
Posted on by 71

Hi all

In my Power Apps form, I have several date picker fields. I notice Power Apps lets me enter invalid dates (ex: 5/12/23). It doesn't give me an error, so I think I'm saving the date, but it actually doesn't save because of the 2 digit year. 

 

How can I alert the user about this? I found another post that said to insert a text box next to the date picker with the Text property: If(IsBlank(DataCardValue01.SelectedDate), "", IsMatch( Text(DataCardValue01.SelectedDate, "[$-en-US]dd/mm/yyyy"), "^\d{2}\/\d{2}\/\d{4}"), "", "Date format must be dd/mm/yyyy")

 

But it doesn't work. No matter what date I enter, the words don't appear. 

 

Any advice?


Thanks 

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    two things you can do, whatever submits that form change its display mode to

    If(IsBlank(DatePicker1.SelectedDate),DisplayMode.Disabled,DisplayMode.Edit)

    where you change DatePicker1 to the name of the Actual DatePickerControl on the card

     

    secondly design a warning message label, put it right below the datepicker and make its visible

    IsBlank(DatePicker1.SelectedDate)

     

    again where datepicker1 is the name of the actualt datepicker control we are referencing

     

    putthing these two together will restrict the user from submitting the form at all and tell them why they cant

  • rutica Profile Picture
    71 on at

    Thanks @TheRobRush  but the field is allowed to be blank. I just want a message next to the Date Picker that alerts the user if they enter an invalid date (ex: a 2 digit year).

     

    For example, I have 10 date fields and I entered 10 dates with 2 digit years. I clicked Save and Close and got the OnSuccess message. But when I went back to the form, none of the dates had been saved. So I want to alert the user when they enter an invalid date. 

     

    The IsBlank doesn't do anything for invalid dates. 

     

    Thanks

  • SebS Profile Picture
    4,882 Super User 2026 Season 2 on at

    @rutica 

     

    This format provides a static number of characters using Len() function.

     

    If(Len(Text(DatePicker1.SelecteDate,"dd/mm/yyyy")) < 10,"incorrect Date","") stick this to label or place it in OnChange property and rather text use Error msg

     

    I forgot You need to format it as Text  as well

  • rutica Profile Picture
    71 on at

    Hi @SebS  Thanks for writing.

    I tried your code in a label and it works, but it displays the message even when the field is blank. 

     

    So I tried to add IsBlank to the label's Text property as shown below, but I wasn't successful, it still shows the message even when the field is blank. 

    If(IsBlank(DataCardValue45.SelectedDate), "",If(Len(Text(DataCardValue45.SelectedDate,"dd/mm/yyyy")) < 10,"incorrect Date",""))

    I tried including this code in the DataCardValue45 InputTextPlaceholder property, but still no luck:

     If(IsBlank(Self.SelectedDate), Text(Blank()))

     

    rutica_0-1683949899588.png

    Thanks

  • rutica Profile Picture
    71 on at

    @WarrenBelz  Do you have any advice for me? How do you handle your date picker fields in your forms? 

     

    Thanks

  • WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    Hi @rutica ,

    As @SebS and @TheRobRush have noted, the problem with a Date Picker control when IsEditable is true is that it is just for that - editing dates already selected. SelectedDate is the only property you can test and if you edit with an invalid format, it simply does not update.

  • rutica Profile Picture
    71 on at

    Thanks for writing @WarrenBelz . So what do you do with non-required date fields in your PowerApps form? I'm wondering what is the best practice?

     

    What I decided to do is: I changed IsEditable to true. And I put a label next to each date field with @SebS 's code: 

    If(Len(Text(DataCardValueXX.SelectedDate,"dd/mm/yyyy")) < 10,"Enter a 4 digit year or the date won't save","")

     

    My date fields are not required, so it's not ideal since the label is showing for blank values. But at least the text goes away if the user enters a correct date. But I think it looks silly:

    rutica_0-1684201884556.png

     

    Thanks

  • SebS Profile Picture
    4,882 Super User 2026 Season 2 on at

    @rutica 

     

    Ok, the issue here is if you set DatetimeFormat.ShortDate no matter what, if the user enters the wrong date, the field does not record a change and considers DatePicer filed as Blank. This prevents You from creating any rules when the user enters the wrong Date, and there is no fix for that than a label stating, "Hey User, this is the format you need to use", which does not look great 🙂 So best to allow users just use Datepicker and not play with Manual data entry.

     

    Now I'm assuming the Milestone date can have a range of Years, and to make the experience easy for the user, You decided that they can enter the date manually to speed it up. Is that the reason?

     

    If so, please not user can easily change the date in the date picker by clicking on the date on the screen

     

    SebS_0-1684267434729.png

     

    Now if this is not the case, there is a solution that I can provide to sort out this dilemma and it will look good and have all functionalities but it's more thinking out of the box and very dirty trick what will take time to explain so I would like to avoid this 🙂

     

     

  • rutica Profile Picture
    71 on at

    Thanks for writing @SebS 

     

    If IsEditable=false (meaning users must only use the date picker), then:
    • tab stops don’t work for that field
    • it forces users to use the clunky date picker
    • you can’t easily delete a date once it’s entered (it's doable, but requires buttons, variables, code, and turning on Formula-Level Error Management in Settings)


    Overall, this seems like an oversight on Microsoft's part- the form should automatically alert the user that an invalid date was detected.

     

    I did just yesterday learn the drop-down Year trick on the date picker! It's not intuitive that the Year can be a drop down. But thanks for the screenshot! I'm sure it will help many others. 🙂

     

    I'll just keep my form as-is. It's not perfect, but it should do the job. 

     

    Thanks again!

  • SebS Profile Picture
    4,882 Super User 2026 Season 2 on at

    @rutica

     

    I would switch to TextInput in this scenario, and OnChange apply Ruls to date with a notification

     

    It will look like this.

     

    If(
     !IsMatch(
     TextInput4.Text,
     "^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"
     ),
     Notify(
     "You entered a invalid date format, please enter value in dd/mm/yyyy format",
     NotificationType.Warning
     );
     Reset(TextInput4)
    )

     

    And no problem 🙂

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard