Tutorial: Data entry using masks

Scriptcase provides different approaches to validate incoming data; by using the default mask, the standard validation or we can even create a code for advanced validations.

This example covers the use of forms with masks for data entry and how to validate the social security number using ajax.

In the example above, we can see the formatting of whole numbers, decimal numbers, currency, date / time, texts and others.

Creating a new Form

Now we will see a practical example of a form using custom input masks and a routine for validating the SSN (social security number) using ajax.

Note:

If you have any questions on how to create a Form, go to: 
Creating a new Form

1. Create a new Form-type application based on the “Employees” table , and then select the “Single Record” option .


Configuration of the Form.

2. Still in the Form settings, if you want a better display of the Records, select the “Fields” tab and change the name of the highlighted fields, as shown below, then click “Create” .

3. After creating the Form, access the “Field Positioning” tab in the application menu .

4. Select the fields: EmployeeID, FirstName, Title, BirthDate, SSN and HomePhone.

Adding masks to the SSN and HomePhone fields

5. In the application menu, access the ” Fields ” tab and click on the “HomePhone” field


HomePhone field.

6. Navigate to the “Display Mask” option and add the following Mask: ( ###) ### – ####; ### – ####

7. In the application menu, still in the ” Fields ” tab , click on the “SSN ” field .

You can use the semicolon to add more masks to the same field.

8. Navigate to the “Display Mask” option again and add the following Mask: ### – ## – ####

note:

You can use a semicolon to insert two masks for a field.

Creating a PHP method for SSN validation.

9. In the application menu, access the “Programming” tab and access the “Internal Libraries” item .

10. Navigate to the “Internal Libraries – Scriptcase” editing tab and enable the sc_ssn.php Library

11. Now open the PHP Methods folder in the menu and click on New Method.

12. Click on Create and name it ValidateSSN.

13. Copy the following code into the field created in the previous step (13):

if ( {SSN} != '') {
    $oSSN = new scSSN();	
    if (!$oSSN->ValidateSSN({SSN})) {
        sc_error_message("SSN Inválido");
    }
}

Creation and Ajax Event to the SSN field.

14. Open the Ajax Events folder in the menu and click on New Ajax Event

15. Set the event as the image below:

16. Add the following code to the created event:

Tutorials in the same category

Tutorial: Multi Step Form

In this sample we’ll see how to create a multi step form. The form will be more nice, intuitive an...

Responsive login form 3

To learn how to use the templates available within the ScriptCase in the security module, follo...

Responsive login form 2

To learn how to use the templates available within the ScriptCase in the security module, follo...

Responsive login form

To learn how to use the templates available within the ScriptCase in the security module, follo...

Comment this post