CFv4 Validation

How can I add a mask to format a form input?

Sometimes it would be helpful to control the format of an entry in a text input to make sure that it is a date, or a money amount, or a credit-card number, . . . To do this we can add ‘masks’ to the input which will only allow certain kinds of input. This FAQ explores how to use the MeioMask library to do this. 

How can I add Auto Client side validation?

Client side validation is the checks on input values that are run in the form page and usually show errors as 'bubbles'. ChronoForms has several ways of setting this up and this FAQ talks about the Auto JavaScript Validation action.

How is client-side JavaScript validation enabled?

The client-side JavaScript validation is the validation that shows error tips when the page is viewed in the browser. There are several ways to set this up depending on how your form is built and this FAQ tries to explain them. There is also a list of the available validations.

How can I change the language used in Validation messages?

ChronoForms v4 uses the FormCheck validation library that has support built in for about twenty languages. This FAQ shows you how to set them up for a single or multi-language site and how to add a new language.

How can I sanitize my form data?

When users submit data from a form they are free to enter anything they like into the form inputs - including corrupt, unwanted or just plain malicious (i.e. dangerous) content. While clientside validation can block user errors it is easily bypassed by turning JavaScript off and so does not provide any real protection for your site.
 
ChronoForms does no server filtering, sanitization or validation on submitted form data by default.

How can I identify 'required' inputs?

It's very helpful to users to identify required inputs in some way or other. You can do this in ChronoForms by editing the input labels to add a *, or using a class to set the label. This FAQ uses JavaScript to identify the required inputs and add markers and classes when the page loads.

Handling serverside validation errors . . .

By default ChronoForms shows errors from serverside validation at the top of the page and also in a message attached to the input where the error came from.
In this FAQ I've started to collect some notes on different ways of handling errrors.

How can I use JQuery on my site?

jQuery is a JavaScript library that is increasingly found in some Joomla! modules and templates. This is perfectly OK as long as jQuery is in no-conflict mode. If it isn't then it will probably cause a JavaScript conflict and break your form validation.

How can I run Auto and Custom Serverside Validation together?

Running either Auto Serverside Validation or Custom Serverside Validation separately is straightforward. But if you want to use both then adding Event Loops means that the second one will only be run if the first one finds no errors. Here is a way to link them together.

How do I use Custom Serverside validation?

Serverside validation is important to help you validate the form data and to protect your site from malicious submissions. 

How can I add Auto Serverside Validation?

ChronoForms has two separate kinds of validation built in. Clientside validation runs in the browser, uses JavaScript and helps the user complete the form correctly. Serverside validation runs on the server after the form is submitted and checks the submitted data. This FAQ tells you how to set up some basic 'auto' serverside validation that has similar checks to the clientside validation.

What decides if clientside validation is enabled?

There are several ways in which the JavaScript Validation files (and the CSS files can be enabled or disabled. Here's the logic used in CFv4 RC3.4

My alphabet uses characters other than a-z . . .

The ChronoForms alpha and alphanumeric validation uses a strict test and will allow only a-z, A-Z. For many languages this isn't useful.
 
Here are some workarounds:

My form validation doesn't work

If the client side validation - the validation that shows bubble messages by the input boxes - on your form doesn't work then there is probably a JavaScript error on the page.

How do I set up user validation in my form?

A short video showing you how to set up basic clientside validation for your form.

How can set client-side validation options?

ChronoForms uses the MooTools.Floor FormCheck library for client side validation. The library has many options and only a small sub-set is included in ChronoForms and there is no built-in way of setting other options.
However if you use my custom Show HTML [GH] action there is a tab where you can set custom FormCheck options.

How can I validate the length of a text input?

Sometimes you need to check that a form input has a text string of a specific length, or is not longer or shorter that some specific values.

You can do this very simply by adding an entry to the Field Class box input element:

How can I validate a number?

There are many different ways in which numbers can be entered into forms. The exact validation that you need will depend on the design of your form and the kind of number that is being entered. This FAQ talks mostly about Clientside validation using JavaScript for which ChronoForms uses the MooTools FormCheck library. 

How can I filter submitted email addresses?

You can use Clientside JavaScript validation to do a first check on whether an email address is valid or not but that is easily by-passed so you need to add a Serverside validation check as well.

How can I confirm an email or password input?

Sometimes you need to check that two form inputs have the same values entered in them. Most often this is to confirm that a password or an email has been entered correctly.