If text box is blank, show “Input Required” error, if txt box is not empty, make popup visible

Occasional Contributor
I have a text box where a user must enter a number (price). There are also popup object grouped together. When a user clicks the submit button, the text box should be controlled if there a value there that 1. is greater than a value in a SharePoint list column, and 2, if the column in the SharePoint list is blank, it should check that the value in the text box is greater than 0. If it meets this Criteria, the popup (which contains all the pop up objects) should be displayed (visible).

I’m pretty new to this and I went through a few if statemetns and tried to incorporate the update context unfortunately without success.

Thank you so much in advance for ur assistance
1 Reply

Hi @katzgroup !


I would usually take a different approach to this, validating the user input before allowing them to submit.  See what you think of this idea, and let me know if you'd like to approach it differently:


For this example, I have a variable that holds my Sharepoint list item called varCurrentListItem, and in that list there is a number column called NumberColumn.


First, on my number input field, I have the following code in BorderColor:



If(IsNumeric(Self.Text),RGBA(0, 18, 107, 1),RGBA(255,0,0,1))



This will put a red border around the text field if someone enters a non-numeric value.


Then, on my number input field OnChange event, I have the following:



            !IsBlank(varCurrentListItem.NumberColumn) || !IsEmpty(varCurrentListItem.NumberColumn),
            Value(Self.Text) > Value(varCurrentListItem.NumberColumn)
            IsBlank(varCurrentListItem.NumberColumn) || IsEmpty(varCurrentListItem.NumberColumn),
            Value(Self.Text) > 0
        Value(Self.Text) > 0,
        UpdateContext({isValid: true})
    UpdateContext({isValid: false})



This checks if the number entered into the text input is:


1. If the SharePoint column is blank/empty,, higher than 0

2. If the SharePoint column is not blank/empty, higher than the value in the column


I Use IsEmpty and IsBlank because I never quite remember which one SharePoint validates against for a blank number column.  the "||" is equivalent to "or" and allows us to evaluate against multiple criteria in our if statement.


So now..."isValid" will only be true if we have a valid number that fits our criteria.  We can use it to allow someone to click on the "Submit" button.  My submit button has the following code in DisplayMode:






This code only enables the button to be clicked if "isValid" is true.


And finally, the OnSelect on my submit button looks like this:






So when we click the button (which can only be clicked if our number is already valid), we set varShowPopup to true.


Now I can use varShowPopup to show my popup, placing this in the Visible property of my popup group:







I've attached a copy of the zipped .msapp file to this post for reference.


Let me know if you need any more assistance around this.