Hello,
In power Apps I have a date picker :
And I want to show a validation erreor ounce the user enters an invalid date manually like this :
Because when I enter manually data like this, it doesn't show any kind of error and after I submit my form the invalid manually entered date isn't saved which means somehow the power apps knows it is not correct... Is there a way that power apps tells me the value is not good before submitting ounce I enter the wrong date manually and click outside the text box please ?
Thank u
Hi @choco_01 ,
When you use Patch or SubmitForm function, you can do check if the format is valid or not -
If(IsBlank(DatePicker1.SelectedDate),Notify("message", NotificationType.Error), SubmitForm(FormName))
I do not want to check if the field is blank or not, but the "how" power apps resets it to blank after finding that the format is not valid. Because I can submit my form if by default the date value is blank but if it is invalid I sould not be able to submit and a validation error should appear...
My problem is how to check if the manually entered date is invalid, any solution please ?
Hey @choco_01
Found a previous post which has similar thing that you require, though the solution has not been accepted but you can try to make a formula similar to this:
If(!IsMatch(Text(valueTerminationDateED.SelectedDate), "\d{1,2}/\d{1,2}/\d{4}") || Value(First(Split(Text(valueTerminationDateED.SelectedDate), "/")).Result)>12 || Value(Last(FirstN(Split(Text(valueTerminationDateED.SelectedDate), "/"))).Result)>31, "Please input correct format datetime", "" )
Rest I will try it on my end if it works.
If you add any value in the date picker that is not in proper format (date format), the DatePicker.SelectedDate will return blank. Using this you can check whether the date in datepicker is in proper format or not.
By default my date is blank so there is times the user can submit without putting in any date
You can set the IsEditable property to false. By doing so, users will not be able to enter dates, they can only select the date from datepicker
Not possible because I need to have the possibility to put it manually too. No way to know if the manual value is valid ?
Well, as far as i have seen, we cannot do that because if you want to check the date format, you will first need to extract the value from datepicker. In case of incorrect date, it returns blank,
DatePicker1.SelectedDate is returning Blank().
If we can extract the value from date picker then we can check the format by creating our own formula.