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 / how I can validate num...
Power Apps
Unanswered

how I can validate number and date

(0) ShareShare
ReportReport
Posted on by

Hi

 

I want build form when the user insert number in box that is greater than 3 times in label number not accept it and when the year of joining date is less one year from current date no accept it also.

 

I am very glad to share us the suitable formula so I can try it in my FORMS.

Categories:
I have the same question (0)
  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @poweruser99 

    On possible way to do a validation is using something like this:

     

    If(Value(txtUser.Text) > (3*Value(txtNumber.Text)),"ERROR","All OK") 

     

    Add two textboxes on your screen. Name them txtUser and txtNumber

    Add a label on your screen and use the formular above as the expression for the Text property.

     

     

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @poweruser99 

    And here is the formula to do a validation on a Date Picker control

    If(dtpJoiningDate.SelectedDate < DateAdd(Today(),-1,Years),"Error","All OK")

     

    Again, place a Date Picker on your screen and use the above formula on a Labels text property.

     

    If this was helpful please accept as solution.

     

    Thanks

     

     

  • SuperPower99 Profile Picture
    8 on at

    Thank u PowerRanger for ur fast respond.

    The formula is great but how I can deny the user to submit the form if the formula is ERROR...

  • SuperPower99 Profile Picture
    8 on at

    by the way the date is already derived from sharepoint so the the date is in label.

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @SuperPower99

    Is this a custom Form or a standalone app? 

  • SuperPower99 Profile Picture
    8 on at

    its custom form I created and I import the gallery form from SharePoint list.

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on at

    @SuperPower99 

    There are many ways to accomplish this. You must know that for customized SharePoint Forms you can't hide the Save button. So you have to adjust the OnSave Property for the form which gets called when you click the save button in SharePoint. My Formular looks like this:

    If(
     And(!varFirstNameHasError),
     SubmitForm(SharePointForm1),
     Notify(
     "Please correct errors...!",
     NotificationType.Error,
     2000
     )
    )

    PowerRanger_1-1644240519103.png

     

     

    I this form I have implemented a custom validation for the Field FirstName which is of type Textinput.

    1. Unlock your Datacard

    2. Select Textinput control

    3. Edit OnChange Proeperty

    If(
     Len(Self.Text) < 10,
     Set(
     varFirstNameHasError,
     true
     );
     Set(
     varFirstNameErrormessage,
     "Firstname to short"
     ),
     Set(
     varFirstNameHasError,
     false
     );
    )

    I check if the Length of the Text smaller than 10. If Yes, I set variable varFirstNameHasError to  true and also set a ErrorMessage variable. If it is greater than 10 I set the variables to false - which is my indicator that there are no Errors.

    PowerRanger_2-1644240598333.png

    Now we need to display the Error to the user

    1. Select the ErrorMessage Label of that DataCard

    2. Adjust the Text Property

    If(varFirstNameHasError,varFirstNameErrormessage,Parent.Error)

    PowerRanger_3-1644240704699.png

     

    Save and Publish. Let me know if it worked on your side.

     

    Please click Accept as solution 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 Thumbs Up.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

#2
11manish Profile Picture

11manish 224

#3
Valantis Profile Picture

Valantis 181

Last 30 days Overall leaderboard