Tuto WEBDEV 25
56 Part 1: Discovering WEBDEV Checking the password To check the password, we are going to create the edit control allowing the user to type his password twice. Then, we will write the WLanguage code required for the check. ▶ Create a new edit control. The caption of this control is "Check" and its type is "Password". ▶ The WLanguage code for checking the password must be written in the events associated with the "SAVE" Button control. 1. Click the "SAVE" Button control and press F2. 2. This check consists in comparing the value typed in the "Password" control and the one typed in the "Check" control. The server is not required to perform this check: it can be performed locally in the browser. 3. We are going to type the following code in the browser "Click" event: IF EDT_Password<>EDT_Check THEN Info("Error, the passwords are different.") EDT_Password = "" EDT_Check = "" ReturnToCapture(EDT_Password) END 4. Let’s study this code: • The IF statement is used to perform an action on a condition. In our case, the action is performed if the "Password" and "Check" controls are different (’<>’ operator). • In case of difference, the edit controls are "cleared": an empty string is assigned to them. • ReturnToCapture is used to position the cursor in the specified control (the "Password" control here) without running the code that follows. In our case, if the passwords entered are different, the "Password" control takes the focus and the code being run is stopped: the server code that is used to save the information in the database will not be run. ▶ Run the test of this page: 1. Click the icon among the quick access buttons. 2. Enter the following information in the page that appears in a browser: • Last name: "Doe" • First name: "Peter" • Email: "Peter.Doe@gmail.com " • Login: "Peter" • Password: "Peter" • Check: "Louis" 3. Click "SAVE". 4. An error message is automatically displayed to indicate that the passwords are different. 5. Validate this message. 6. Close the browser.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==