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

a

(1) ShareShare
ReportReport
Posted on by 691
 
Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    154,445 Most Valuable Professional on at
    Hi @s44,
    A bit different approach - your various message requirements made this more complex
    If(
      "/" in Self.Text;
    With( {dateParts: Split(Self.Text; "/")}; With( { day: Value(First(dateParts).Value); month: Value(Index(dateParts; 2).Value); year: Value(Last(dateParts).Value); enteredDate: DateValue(Self.Text; "fr-FR"); minValidDate: DateAdd(Today(); 3; TimeUnit.Months); maxValidDate: DateAdd(Today(); 3; TimeUnit.Years) }; With( { _ErrorDates: month = 1 && day > 31 || month = 2 && day > If(Mod(year; 4) = 0; 29; 28) || month = 3 && day > 31 || month = 4 && day > 30 || month = 5 && day > 31 || month = 6 && day > 30 || month = 7 && day > 31 || month = 8 && day > 31 || month = 9 && day > 30 || month = 10 && day > 31 || month = 11 && day > 30 || month = 12 && day > 31; _ErrorFormat: !IsMatch(Self.Text; "^\d{2}/\d{2}/\d{4}$"); _ErrorMax: enteredDate > maxValidDate; _ErrorMin: enteredDate < minValidDate }; With( {_Error: _ErrorDates || _ErrorFormat || _ErrorMax || _ErrorMin}; If( _Error; Notify( If( _ErrorDates; "Date invalide."; _ErrorFormat; "Date invalide. Veuillez entrer une date au format JJ/MM/AAAA."; _ErrorMax; "La date doit être inférieure à 3 ans."; _ErrorMin; "La date doit être supérieure à 3 mois." ); NotificationType.Error );; Reset(Self) ) ) ) )
      ) )

     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Hii_iii Profile Picture
    691 on at
    .
  • WarrenBelz Profile Picture
    154,445 Most Valuable Professional on at
    Hi @s44,
    Please see addition (which is good to check anyway)
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • Hii_iii Profile Picture
    691 on at
    .
  • Verified answer
    WarrenBelz Profile Picture
    154,445 Most Valuable Professional on at
    OK - I do not think it is possible (without a lot of brain frying) to cover every possibility of what a user might enter. Also if you want to change numbers to xx/xx/xxxx "on the fly", you will need to set the Default of your text box to (in the example) varDate, so you may need to clear this before the user enters the next date, My best effort below
    If(
       Len(Self.Text) > 0;
       If(
          !("/" in Self.Text) && Len(Self.Text) = 8 && IsNumeric(Self.Text);
          UpdateContext({varDate: Left(Self.Text; 2) & "/" & Mid(Self.Text; 3; 2) & "/" & Right(Self.Text; 4)});;
          Reset(Self);
          UpdateContext({varDate: Self.Text})
       );;
       With(
          {dateParts: Split(varDate; "/")};
          With(
             {
                day: Value(First(dateParts).Value);
                month: Value(Index(dateParts; 2).Value);
                year: Value(Last(dateParts).Value);
                enteredDate: DateValue(varDate; "fr-FR");
                minValidDate: DateAdd(Today(); 3; TimeUnit.Months);
                maxValidDate: DateAdd(Today(); 3; TimeUnit.Years)
             };
             With(
                {
                   _ErrorDates: 
                   month = 1 && day > 31 || 
                   month = 2 && day > If(Mod(year; 4) = 0; 29; 28) || 
                   month = 3 && day > 31 || 
                   month = 4 && day > 30 || 
                   month = 5 && day > 31 || 
                   month = 6 && day > 30 || 
                   month = 7 && day > 31 || 
                   month = 8 && day > 31 || 
                   month = 9 && day > 30 || 
                   month = 10 && day > 31 || 
                   month = 11 && day > 30 || 
                   month = 12 && day > 31;
                   _ErrorFormat: !IsMatch(varDate; "^\d{2}/\d{2}/\d{4}$");
                   _ErrorMax: enteredDate > maxValidDate;
                   _ErrorMin: enteredDate < minValidDate
                };
                With(
                   {_Error: _ErrorDates || _ErrorFormat || _ErrorMax || _ErrorMin};
                   If(
                      _Error;
                      Notify(
                         If(
                            _ErrorDates;
                            "Date invalide.";
                            _ErrorFormat;
                            "Date invalide. Veuillez entrer une date au format JJ/MM/AAAA.";
                            _ErrorMax;
                            "La date doit être inférieure à 3 ans.";
                            _ErrorMin;
                            "La date doit être supérieure à 3 mois."
                         );
                         NotificationType.Error
                      );;
                      UpdateContext({varDate: ""});;
                      Reset(Self)
                   )
                )
             )
          )
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • WarrenBelz Profile Picture
    154,445 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   

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!

Leaderboard > Power Apps

#1
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard