Forums

Custom Server-Side Validation

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.
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 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...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.