Cert++
Close

Form definition validation rules versus client-side validation

Key Takeaway

Rules in the form definition run on the server, so they still apply when browser checks are bypassed. The parse and regexp check runs before the length checks. A string that fails its regexp therefore gets parse-error, not range-error, even if it is also too long.

B2C Commerce forms can be validated in two places. On the server, rules written into the XML form definition check the submitted data. In the shopper's browser, client-side checks do the work. Simple forms that store no data can rely on client-side validation alone. Forms that store data or need server-side validation should use a form definition. The server-side rules run in a fixed order, and that order decides which error message a field shows.

Choosing a form type

Choose the form type by what the form needs to do.

If the form doesn't store data, is easily localized, and only needs client-side validation...

It is a simple form, so it can be a standard HTML form that uses AJAX for validation and error rendering.

If the form stores data, needs server-side validation, or has sophisticated localization...

It is a complex form, so it should use a B2C Commerce form definition.

A simple form must meet all three simple conditions. A form that meets any one of the complex conditions should use a form definition.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a requirement to accept, validate, and persist information from a storefront customer, modify the appearance of a form, add validation and cross-site request forgery (CSRF) protection, and use bindings to process fields

0/9

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.