web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Validation on dropdown...
Power Apps
Unanswered

Validation on dropdown and textbox

(0) ShareShare
ReportReport
Posted on by 504

So I have multiple dropdown and text input with an validation label on each. 

Here is a sample code of visible on validation label.

TextBox: If(DataCardValue17.Text="",true,false)

Dropdown: If(IsBlank(DataCardValue21.Selected.Value),true,false)

What I want to do is for all my validation label to appear once I click on the button submit.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @nagestiada 

    So you have Visible properties of the validation label that there is nothing either in DataCardValue17 (text) and DataCardValue21 (dropdown)? How have you coded this on the Validaton Label - I don't quite understand and also what is the code on your Submit button?

  • nagestiada Profile Picture
    504 on at

    Hi @WarrenBelz 

     

    Yup I have validation label that gets visible when textbox is empty.

     

    for my submit button here is my code.

    If(DataCardValue17.Text="" || IsBlank(DataCardValue16.Selected.Value) || IsBlank(DataCardValue21.Selected.Value) || 
    DataCardValue16.Selected.Value="Other" && DataCardValue18.Text="" || DataCardValue21.Selected.Value="Yes" && DataCardValue6.Text="" && DataCardValue7.Text="",UpdateContext({ValidationLabel:true}),UpdateContext({Popup:true}))

     

    Please note that if DataCardValue16 dropdown is selected into Other, a required text input will be visible (DataCardValue18)
    That's why I added &&

     

    Button is working, however the labels do appear even if i am not clicking the submit button yet. 

  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @nagestiada ,

    I am still a little confused here with your requirements as compared with your code. Firstly, this code

    If(
     DataCardValue17.Text="" || 
     IsBlank(DataCardValue16.Selected.Value) || 
     IsBlank(DataCardValue21.Selected.Value) || 
     DataCardValue16.Selected.Value="Other" && 
     DataCardValue18.Text="" || 
     DataCardValue21.Selected.Value="Yes" && 
     DataCardValue6.Text="" && 
     DataCardValue7.Text="",
     UpdateContext({ValidationLabel:true}),
     UpdateContext({Popup:true})
    )

    needs some brackets around the and/or groups are you trying to do something like

    If(
     (
     DataCardValue17.Text="" || 
     IsBlank(DataCardValue16.Selected.Value) || 
     IsBlank(DataCardValue21.Selected.Value) || 
     DataCardValue16.Selected.Value="Other" 
     )&& 
     ( 
     DataCardValue18.Text="" || 
     DataCardValue21.Selected.Value="Yes"
     )&& 
     DataCardValue6.Text="" && 
     DataCardValue7.Text="",
     UpdateContext({ValidationLabel:true}),
     UpdateContext({Popup:true})
    )

    or this

    If(
     DataCardValue17.Text="" || 
     IsBlank(DataCardValue16.Selected.Value) || 
     IsBlank(DataCardValue21.Selected.Value) || 
     ( DataCardValue16.Selected.Value="Other" && 
     DataCardValue18.Text="" 
     ) || 
     (
     DataCardValue21.Selected.Value="Yes" && 
     DataCardValue6.Text="" && 
     DataCardValue7.Text=""
     ),
     UpdateContext({ValidationLabel:true}),
     UpdateContext({Popup:true})
    )

    As well, you are setting a context Variable called ValidationLabel (this should not be the same name as you label) to true, so how does this relate to the Visible property of your label (what is the Visible property of this)?.

    Lastly how does the code you supplied in the first post relate to what you are doing (when is is on the Visible property of those controls)? Am I missing something here?

     

     

  • nagestiada Profile Picture
    504 on at

    Ohh for the button, ValidationLabel: true,

     

    This is the code for it. I used to have only one label for all validation but I think separate is better. thats why  I made each validation label.

    If(DataCardValue17.Text="" || IsBlank(DataCardValue16.Selected.Value) || IsBlank(DataCardValue21.Selected.Value) ||
    DataCardValue16.Selected.Value="Other" && DataCardValue18.Text="" || DataCardValue21.Selected.Value="Yes" && DataCardValue6.Text="" && DataCardValue7.Text="",true,false)



    Hm,, Do you have any suggestion or workaround with this?

     

    Basically I want all my label to appear after clicking submit not during user input.

  • nagestiada Profile Picture
    504 on at

    @WarrenBelz 

     

    This is what my UI looks like

    nagestiada_0-1593399043070.png

     

    so below the text box the validation label will appear.


    for Other System it will only appear when I click Other

     

    But validation does not work, I need to type something in Other System then removed it so validation will work. Initially, when I click other and don't input something in other it will go still go through while it shouldn't.

  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @nagestiada ,

    I cannot see you data, form or validation logic and you really need to bracket the and/or combinations like below

    If(
     DataCardValue17.Text="" || 
     IsBlank(DataCardValue16.Selected.Value) || 
     IsBlank(DataCardValue21.Selected.Value) || 
     ( DataCardValue16.Selected.Value="Other" && 
     DataCardValue18.Text=""
     )|| 
     (
     DataCardValue21.Selected.Value="Yes" && 
     DataCardValue6.Text="" && 
     DataCardValue7.Text=""
     ),
     UpdateContext({ValidationLabel:true}),
     UpdateContext({Popup:true})
    )

    however if this is the code on the submit button and it results in the required logic, you only need on the Visible property of your Validation Label (I would rename this to something like vViewLabel

    ValidationLabel

     as it will be either true or false and reflect directly in the Visible property.

    It is easy to have one control as long as your If statement logic produces the right result.

     

    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.

  • v-bofeng-msft Profile Picture
    on at

    Hi @nagestiada :

    Are you looking for the following features:

    • Before clicking the submit button: verify that the label is not displayed
    • After clicking the submit button: Qualified verification display

    If my assumption is correct,maybe you can try this solution:

    1)set the app's OnStart property to :

     

    UpdateContext({ValidationLabel:false})

     

    2\set the submit button's OnSelect property to :

     

    UpdateContext({ValidationLabel:true})

     

    3\set the label's Visible property to:

    If(ValidationLabel&&Analyzing conditions,true,false) /*Analyzing conditions is you analyzing conditions like (DataCardValue17.Text="" || IsBlank(DataCardValue16.Selected.Value) || IsBlank(DataCardValue21.Selected.Value) */

    Best Regards,

    Bof

  • nagestiada Profile Picture
    504 on at

    Hi @WarrenBelz 

    Your code worked, but I need to type something in the textbox and remove it so that the validation will take effect..

     

     

    If(
     DataCardValue17.Text="" || 
     IsBlank(DataCardValue16.Selected.Value) || 
     IsBlank(DataCardValue21.Selected.Value) || 
     ( DataCardValue16.Selected.Value="Other" && 
     DataCardValue18.Text=""
     )|| 
     (
     DataCardValue21.Selected.Value="Yes" && 
     DataCardValue6.Text="" && 
     DataCardValue7.Text=""
     ),
     UpdateContext({vViewLabel:true}),
     UpdateContext({Popup:true})
    )

     

     

    I am confused, I tried visible  to vViewLabel of my vViewLabel but it does not work.

     

    Initially view vViewLabel should only be visible when button is clicked.

  • nagestiada Profile Picture
    504 on at

    Hi @v-bofeng-msft 

     

    for validation to take effect, I need to type something to the input box and remove it? 

     

    For example. I clicked on Yes on the dropdown, a text input will appear which is working. But when I click submit it does submit. But when I input something on the text input and remove it the validation only just take effect.

  • Verified answer
    WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    @nagestiada , 

    Try either making the Default of the Text boxes "" (empty string) or use this code.

     

    If(
     IsBlank(DataCardValue17.Text) || 
     IsBlank(DataCardValue16.Selected.Value) || 
     IsBlank(DataCardValue21.Selected.Value) || 
     ( DataCardValue16.Selected.Value="Other" && 
     IsBlank(DataCardValue18.Text)
     )|| 
     (
     DataCardValue21.Selected.Value="Yes" && 
     IsBlank(DataCardValue6.Text) && 
     IsBlank(DataCardValue7.Text)
     ),
     UpdateContext({vViewLabel:true}),
     UpdateContext({Popup:true})
    )

     

    Also put a table on the screen with vViewLabel and see if it turns to true when it should.

     

    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard