Custom Server-Side Validation

How to implement custom client-side validation in ChronoForms v5.

Overview

The issue occurs when using an incorrect JavaScript method to validate a field value.
Use the .val() and .match() methods in your custom function and add the error message to the 'Title' field in the element settings.

Answered
Qu Quidong 22 Apr, 2014
Hello,

I tried to add a custom validation for a field but it doesn't work.

I have added to the field for validation a "custom function" with the name "customCheck"

Then in the onload Event before everything else I have added a Load Javascript block.
Inside the block I have added my function:

function customCheck(el){
  if ( !el.value.test(/[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}/) ) {
    el.errors.push("Please enter a valid IBAN!");
      return false;
  } else {
    return true;
  }
}


Am I doing something wrong? Nothing different happened. Can somebody help?

Thanks a lot in advance.
Qu Quidong 30 Apr, 2014
Hello,

I checked the links. The second link handles the topic, but the solution doesn't work.
Can somebody help?

Thanks a lot in advance.
Max_admin Max_admin 30 Apr, 2014
Answer
Please try to edit the code a little bit since this is v5:

function customCheck(el){
  if ( !el.val().match(/[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}/) ) {
      return false;
  } else {
    return true;
  }
}

Your error message should be added to the "Title" field in your element settings!
Additionally, this is a custom client side validation, not server side!

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.