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 / Conditionally make a C...
Power Apps
Unanswered

Conditionally make a Card required, either a Radio button is checked OR a checkbox is checked + free text value is entered

(0) ShareShare
ReportReport
Posted on by 3,514

I have the following Card, which contain:-

 

1) Radio button

 

2) CheckBox

 

3) Free text input

 

3arrows.png

 

now how i can force this rule:-

If the checkbox is checked then the user must enter a free text inside the input field, while if the checkbox is not checked the user must select a radio button option? any advice on how i can achieve this?Thanks

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    Set your Required property for the Datacard to:

    (yourCheckBox.Value && IsBlank(yourTextInput)) ||
    IsBlank(yourRadio.Selected.Value)

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi

     

    You can create a variable (varCheckEntryType) and set it initially as false. 

    I presume that the checkbox is by default unchecked so you can create a condition in the app onStart and on the checkbox onSelect you can put:

    Set(varCheckEntryType;!varCheckEntryType)

    The displaymode of the radio would be:

    If(varCheckEntryType;DisplayMode.Disabled;DisplayMode.Edit)

    And the displaymode of the textinput:

    If(varCheckEntryType;DisplayMode.Edit;DisplayMode.Disabled)

     Additionally, on the OnSelect of the checkbox you can use the Reset function to clear either the radio selection or the textinput selection if you want.

     

    When you submit the form, you can use a if condition to check the variable state (in order to know which input is supposed to be filled, and check its content).

  • johnjohn123 Profile Picture
    3,514 on at

    @RandyHayes  but in this case when i check the check box and i do not enter anything inside the input field, the Card will not be required and i can submit the form with the checkbox checked and empty input field ...

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

     With this formula:

    (yourCheckBox.Value && IsBlank(yourTextInput)) ||
    IsBlank(yourRadio.Selected.Value)

    If your Checkbox is Checked and the input is blank, then the field will be Required.

     

    You will want to make sure you disable your submit button:

       If(yourForm.Valid, Edit, Disabled)

    or validate before submit:

       If(yourForm.Valid, SubmitForm(yourForm))

  • johnjohn123 Profile Picture
    3,514 on at

    @RandyHayes  but this formula :-

     

    (yourCheckBox.Value && IsBlank(yourTextInput)) ||
    IsBlank(yourRadio.Selected.Value)

    is not working as i mentioned. also why i need to manually check if the form is valid before submitting... as this is done out of the box, so the form will not get submitted unless it is valid.. am i correct? or i am missing something?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    You must check the Valid property of the form.  A form will submit if you issue a SubmitForm regardless of the requirements.  The difference is that the submit will then attempt to submit and then fail and then the for will show what is not valid.  

    But, there is nothing that stops you from submitting.  But, checking if the form is Valid will allow you to check first.  This is the primary purpose of the .Valid property of the form.  .Value will be true if all of the fields in the form that have a Required property set to true also have something in the Update property.  If the card is required and the update has a blank value, then the form will not be valid.  

     

    The formula provided should be setting your form property to Required.  Simply setting to required will not stop the Submit.  You need to check the .Valid.

     

    The logic on the Required formula is this:

    CheckBox TextInput Radio Required
    UnChecked Blank Unselected true
    UnChecked Blank Selected

    false

    Checked Blank UnSelected true
    Checked Filled UnSelected false

     

    This should set the required property based on your logic.  

    You WILL need to also make sure your Update property is supplying the proper value.

     

    Your Update property should be:

    Coalesce(yourRadio.Selected.Value, yourTextInput.Text)

     

    However, there are some real questions on how this entire solution is going to work for you properly in your scenario - I mentioned this in your other post.  You might want to look over that first!

  • johnjohn123 Profile Picture
    3,514 on at

    @RandyHayesI already have this formula inside the update for the data card:-

     

    If(varManualAdd,{Value : TextInput2.Text},Radio1.Selected)

    where varManualAdd will be set to true if the checkbox is checked, and will be set to false if the checkbox is unchecked...  so in my case if i check the checkbox and leave the input text field empty the update property value will be empty...but i will not get any required message based on this formula:-

     

    (yourCheckBox.Value && IsBlank(yourTextInput)) ||
    IsBlank(yourRadio.Selected.Value)

     

    not sure if we are on the same page? thanks

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    No, it is not going to display any message.  If you want some message, then you need to provide that message.  

    The built-in message is based on Datasource errors, not general form errors (validation).

     

    You don't need any variables for your checkbox, you can just check that value.  Otherwise you will need to maintain a variable in your app.

     

    So, to update, the Update property should be:

    If(yourCheckBox.Value,
     {Value : TextInput2.Text},
     Radio1.Selected
    )

     

  • johnjohn123 Profile Picture
    3,514 on at

    @RandyHayes  but using

     If(yourForm.Valid, SubmitForm(yourForm))

    is really bad as all the data source built-in errors will stop showing and the users will just try to click on the submit button and the form will not get submitted nor it will show any errors.. not sure what need to be done exactly ?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    The built-in errors are from the data source.  You are trying to make a field required in the APP, not in the datasource, so there will never be an error from the datasource.  

     

    As mentioned before, you can still just issue the SubmitForm.  If the field is required and the Update is blank, then you should still see the error message.

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard