Client Side Form Validation
How To Use
There are two things to do :
Open your app , then click Manage Dependencies to call all Dependencies you want , finally click Apply .
Make sure you selected all the Dependencies below .
Before point two , we want to know the details of Dynamic Form .
As we see , the Form contains Two Placeholders
Create your own Screen that you want to use the form inside it , then drag the Form Widget to this screen like this .
Create what you want inside the Form's placeholder1 .
In this Example we Create 3 Inputs (Name , Address, Age)
Create local variable as list datatype (List of FieldRule structure)
- FieldRule structure
Consists of Five Attributes
To store the Widget Id , in our Example we can assign Name Input Id or Age Input Id
We can find the Id in Widgets
Without Id we can't check the Input Validation , It's important to assign the correct Id .
It's important Attribute , we must understand why is it important ?
To answer to this question , we should know why we need the Form Validation .
We need the Form Validation to check the Rules , check the inputs Validation .
Ex : we need to create Form for Personal Information to Register to our Website .
The validation Say " the Name length is between 2 and 50" , "The Age is between 15 and 100", The Address is less than 200" , "Required Fields are Name , Age " ....
We can define our Rules now .
Name Field >> Length Range (2 ,50) , Required
Age Field >> MinValue = 15 , MaxValue = 100 , Required
Address Field >> MaxLength = 200
This Rules can apply to our Form Validation
Our Rules :
Note : You can add more Rules and apply it .
Here we can write the error message to show the User what is the wrong to correct the Data.
We use it if the Field is Required and write our errorMessage Ex :"Field is Required" ,then the Field will be Required and the user must Enter data , if not the error message will appear .
We finished all the Attributes ....
The last step , we assigned the local variable to the Block as Input .
Here we create the Event to know the Form' status ( valid or not Valid)
How we use this Event ..
With this condition we can know if the form is Valid or Not ?
If the Form is Valid Put your code to complete the save Logic .
How we can Assign the rules to local variable ( Rules List )
Click above the screen , then select the OnReady Event to Initialize the Rules List .
We start implement the logic , we want to assign our Fields Rules to this List .
we will add new Item to the list for any Rule ..
Ex : if we need to make the Min Length = 5 characters .
- FieldId
ValidationType = MinLength
Value = 5
ErrorMessage = "Any Message "
Note : We added value to Required Message Attribute so, this input became Required ... and this message will appear if the user left it empty .
Like these steps you can define all your Rules .
Click Publish , then test your app :)
App Link :
https://personal-f2sae852.outsystemscloud.com/TestValidate/Home?_ts=637890275851159656
Thanks For You :)
If there 's any question or Ideas you can contact with
Abduerhman Salama
Profile | OutSystemsAbduerhman Salama | LinkedIn
Ahmed Hosny
https://www.outsystems.com/profile/dyj60vvzxl/overview