I am working on a PowerApp where there is a text field I want to validate. The maximum number of characters is 10 and the minimum number of characters is 9:
1234567-8
12345678-9
if a person enters less than 9 characters or doesn't put - , the form should not be submitted and show a warning message.
I really don't know how I can achieve this. I even thought about putting - before the last character
Please help !
Solved! Go to Solution.
Hi @elaaadani ,
Set OnChange property of the inputText to:
UpdateContext({formatError:
Len(textInputControl.Text)<9 || IsBlank(Find("-",textInputControl.Text))
})
and use this variable value to:
Label ErrorMessage (from the DataCard) -> Visible property value: formatError
and to OnSave property of the SharePointIntegration or the button control -> OnSelect property:
if (!formatError,SubmitForm(YourFormName))
Hope it helps !
Hi @elaaadani ,
Set OnChange property of the inputText to:
UpdateContext({formatError:
Len(textInputControl.Text)<9 || IsBlank(Find("-",textInputControl.Text))
})
and use this variable value to:
Label ErrorMessage (from the DataCard) -> Visible property value: formatError
and to OnSave property of the SharePointIntegration or the button control -> OnSelect property:
if (!formatError,SubmitForm(YourFormName))
Hope it helps !
@gabibalaban Thank you.
I have this problem. When I put this, I have this error "unexpected character "
UpdateContext({formatError:
Len(TextInput2.Text)<9 || IsBlank(Find("-",TextInput2.Text))
})
Hi @gabibalaban Can you please help me with this?
1. Label ErrorMessage (from the DataCard) -> Visible property value: formatError
I have to go to Visible and put formatError ??
2. the button control -> OnSelect property: if (!formatError,SubmitForm(YourFormName))
I don't understand this point . I just send the textbox information to an excel
Have you solved the issue with the formula ?
UpdateContext({formatError:Len(TextInput2.Text)<9 || IsBlank(Find("-",TextInput2.Text))})
formatError is a boolean variable, and here you set the value based on your criteria.
I supose that you save data using a form:
1. Yes, because formatError is a boolean and Visible property of label ErrorMessage expects a boolean value.
2. I wasn't sure how you send data to datasourse. I noticed that you refered to a Form so I thought of 2 posibilities:
a) have a Sharepoint Integration (not the case)
b) have a button on your screen to execute SubmitForm() (now i'm pretty sure that this is it).
Anyway, the idea is to prevent sending data to the datasource (in this case Excel file) if the formatError is true. So, you have to use the formula if (!formatError,SubmitForm(YourFormName)) on the control used to save data.
User | Count |
---|---|
221 | |
98 | |
95 | |
55 | |
34 |
User | Count |
---|---|
273 | |
107 | |
105 | |
60 | |
60 |