+1 (855) 920-2583
Login

A form can be submitted even when some elements in it do not pass validation

Modified on: Fri, 17 Nov 2023 12:07 PM
Original Publishing Date:
2020-01-22

Symptoms

A user can submit a form in Custom UI when some fields in this form are not valid.

Cause

Validation check is not added to onSubmit method

Resolution

You should call aps/PageContainer's validate() method to check if all fields are valid. For example, assuming my PageContainer has an id of 'top':

aps.app.onSubmit = function() {
    var form = registry.byId("top");
    if (!form.validate()){
        console.log("Not all fields are valid");
        aps.apsc.cancelProcessing();
        return;
    }
    // normal processing logic below this line
}

Additional information and examples can be checked on the PageContainer documentation page.

Internal content