How to use the Captcha Validation Rule

by Ombretta Malinverno
9,889 views Published on Nov 27, 2017
Applies to: 7.2 or higher
Table of contents

Introduction

WebRatio Platform gives you the chance to add a Captcha control to the forms of your Web Project.

 

This is the definition of Captcha (source Wikipedia https://en.wikipedia.org/wiki/CAPTCHA):

"A CAPTCHA or Captcha is a type of challenge-response test used in computing to ensure that the response is not generated by a computer. The process usually involves one computer (a server) asking a user to complete a simple test which the computer is able to generate and grade. Because other computers are unable to solve the CAPTCHA, any user entering a correct solution is presumed to be human. Thus, it is sometimes described as a reverse Turing test, because it is administered by a machine and targeted to a human, in contrast to the standard Turing test that is typically administered by a human and targeted to a machine. A common type of CAPTCHA requires that the user type letters or digits from a distorted image that appears on the screen."

 

WebRatio Platform includes several other types of validation rules that cover the most common cases of validation that may be necessary in a Web application. Refer to the "How to model a Simple Validation" article for further details of the other validation types.

Configuring the Captcha validation rule

Suppose you have a page that allows a user to log in to the application, as shown in the following figure. Refer to the "Access Control & Personalization: IFML Model" and the "Access Control & Personalization: Action Definition" online lessons to model the Login pattern.

Let's see the steps necessary to add a Captcha validation rule to the form.

  1. Add a field to the Form Component. Right-click on it and select the Add > Field option. Give a meaningful name to the field (e.g., "Control Code").
  2. Add the "Captcha" validation rule to the "Control Code" field.
  1. Move to the Outline View.
  2. Right-click on the field and select the Add > Validation Rule option.
  3. Select the "Captcha" validation rule in the opening dialog.
  4. Press the OK button to confirm.
  5. Set a name to the validation rule (e.g., "Captcha Control").

In this way, you obtained a login page with a captcha control. You can see the result in the figure below.

Captcha Settings

It is possible to customize the captcha code by setting different properties on the validation rule. All properties are available in the Properties View of the validation rule.

 

  • Characters. It defines the characters list to be used by the captcha code (default is ABCDEFGHIJKLMNPQRSTUVWXYZ123456789). It is possible to choose only a subset of characters, changing the value of this property (e.g., use only numbers: 123456789).

  • Ignore Case. If checked, the comparison is performed while ignoring case sensitivity.
  • Min Length. It defines the minimum number of characters to be used to create the control code (default is 6). If this value is set to a higher one respect to the Max Length property, it is ignored.
  • Max Length. It defines the maximum number of characters to be used to create the control code (default is 6). If this value is set to a lower one respect to the Min Length property, it is ignored.

  • Min Font Size. It defines the minimum font size to be used in the control code (default is 20).
  • Max Font Size. It defines the maximum font size to be used in the control code (default is 35).
  • Font Names. It defines the list of the available font families. The list is separated by pipes (|), (default is Arial|Tahoma|Verdana).
  • Width. It defines the width of the control code container (default is 200).
  • Height. It defines the height of the control code container (default is 50).

  • Color Ranges. It defines the range of colors to be used to render the characters. It is expressed in RGB. It is composed of three couples of values (default is 0,100,0,100,0,100).

  • Background. It defines the color of the control code background. It is expressed in RGB (default value is 255,255,255).

  • Error Message. You can define text that is displayed to the user when the validation fails. The error message supports the usage of special keywords (e.g., fieldName, fieldValue, componentName) that are replaced at runtime by the value entered with the user. See the Captcha validation rule documentation for more specific keyword declaration.