Forums

Spanish NIF validation form

jaume_teixido 20 Feb, 2013
Hello,

I need validate NIF field (8 numbers + 1 letter)
for exemple like 12121212E

exist any class like?
validate['required','%nif']

for me it's enough validate 8 numbers + l letter, is not necessary verify that combination is ok.

really thanks...
GreyHead 20 Feb, 2013
Hi Jaume,

There's nothing built in but you can create a custom validation. Please see this FAQ

Bob
jaume_teixido 20 Feb, 2013
Ok!
like this
function dni(el){
  if ( !el.value.test(/^[0-9]{8}[A-z]{1}$/) ) {
    el.errors.push("Add an error message here");
    return false;
  } else {
    return true;
  }
}

thanks
Alcor 13 Mar, 2014
I've tried this, but I don't get this to work. I use CFv5 with Joomla! 3.2.3 and in the element settings, tab validation, the custom function calls to dni function that it's written in Load Javascript on OnLoad event. What is it that I do wrong?
GreyHead 26 Mar, 2014
Hi Jaume,

Hmm. I think that Max has changed the way you add Custom Validation is CFv5. I believe that he has added a FAQ or a forum post telling you how to do it though. ( later I found this thread ).

Bob
This topic is locked and no more replies can be posted.