cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AkshayManke
Continued Contributor
Continued Contributor

Validation - Form Should not Submit Until Some Value is Added

Hello Everyone,

 

I have developed one App with multiple amount fields. I need a rule/valudation where, the user should not be able to submit the form until he adds some values in the amount field. I tried adding a Popup, but i already have one Popup (Added the code in to the OnSelect button) for making attachments mandatory and, adding another one with is not working as expected.

 

Below the code of OnSelect:

 

If(
    CountRows(DataCardValue20.Attachments) <=0,
    UpdateContext({Popup: true}),
    SubmitForm(InitialForm);
    Navigate(
        Home
    )
)

 

 Can anyone please suggest any logic? 

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @AkshayManke ,

 

I think these two cases can share a pop-up, but the shared pop-up show different message based on the condition(Attachment is empty or Amount is Blank)

Button.OnSelect: 

If(
    CountRows(DataCardValue20.Attachments) <=0 Or IsBlank(AmountDataCarValue.Text),
    UpdateContext({Popup: true}),
    SubmitForm(InitialForm);
    Navigate(
        Home
    )
)

 pop-up.Text:

If(CountRows(DataCardValue20.Attachments) <=0 && !IsBlank(AmountDataCarValue.Text), "Attachment is required!" ,

CountRows(DataCardValue20.Attachments) > 0 && IsBlank(AmountDataCarValue.Text), "Amount is required!",

CountRows(DataCardValue20.Attachments) <=0 && IsBlank(AmountDataCarValue.Text), "Attachment and Amount are all required!")

Hope this helps.

Sik

 

View solution in original post

3 REPLIES 3
eka24
Super User
Super User

This is another approach, Disabled the Submit button Displaymode:

If(CountRows(DataCardValue20.Attachments)<=0,DisplayMode.Edit,DisplayMode.Disabled)

 

Or give Notification

If(CountRows(DataCardValue20.Attachments)<=0,Notify("Please Add Attachment"))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

v-siky-msft
Community Support
Community Support

Hi @AkshayManke ,

 

I think these two cases can share a pop-up, but the shared pop-up show different message based on the condition(Attachment is empty or Amount is Blank)

Button.OnSelect: 

If(
    CountRows(DataCardValue20.Attachments) <=0 Or IsBlank(AmountDataCarValue.Text),
    UpdateContext({Popup: true}),
    SubmitForm(InitialForm);
    Navigate(
        Home
    )
)

 pop-up.Text:

If(CountRows(DataCardValue20.Attachments) <=0 && !IsBlank(AmountDataCarValue.Text), "Attachment is required!" ,

CountRows(DataCardValue20.Attachments) > 0 && IsBlank(AmountDataCarValue.Text), "Amount is required!",

CountRows(DataCardValue20.Attachments) <=0 && IsBlank(AmountDataCarValue.Text), "Attachment and Amount are all required!")

Hope this helps.

Sik

 

AkshayManke
Continued Contributor
Continued Contributor

Hi @eka24 , @v-siky-msft , Many Thanks for helping on this.

 

The solution given by @v-siky-msft has perfectly fitted to the exact requirement.

 

Thanks again to both of you.!!

 

Regards,

Akshay

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (4,335)