How do you use js validation with CFv6?

dzseti 11 Apr, 2017
Not clear to me how to use js (or jquery) validation with CFv6 - any hints or examples, please?
Max_admin 11 Apr, 2017
Hi dzseti,

There is a "Validations rules" box in each field, just write there the rules you want, for example:

required:this field is required
email:please provide a valid email


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dzseti 11 Apr, 2017
How would I add custom rules - say a postcode validation script?
Max_admin 12 Apr, 2017
First of all, you will need to drag a JavaScript element to your section and include a custom function like the one below:

jQuery.fn.form.settings.rules.custom = function(value){
			if(value){
				return true;
			}else{
				return false;
			}
		};

This function here checks if the field is not empty, its name is "custom", then use "custom:message" in the validations rules box.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dzseti 12 Apr, 2017
Thanks, Max. Oddly I was trying something like this, but using 'amount:message' instead of 'custom' and it threw a js error. But now I am using 'postcode:message' and '.rules.postcode' (instead of your 'custom:message' and '.rules.custom') and everything is working fine.

Just another observation for you: when using 2 validators of which one is 'required', the red star only appears against the field when 'required' is the first of the 2
Max_admin 12 Apr, 2017
Thank you, I will check this.

Additionally, you can use this in the "Extra attributes" box:

data-inputmask:'mask' : '99999'


To mask the text box value to 5 numeric digits only if this matches your post code validation.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.