cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
poweruser99
New Member

how I can validate number and date

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.

7 REPLIES 7
PowerRanger
Super User
Super User

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

 

 




​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.
PowerRanger
Super User
Super User

@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

 

 




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

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

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

@SuperPower99

Is this a custom Form or a standalone app? 




​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.
SuperPower99
Regular Visitor

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

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




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

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,705)