Forums

Validation of a field

jw-saarow 18 Nov, 2014
Hi,
I try to make a client side validation.
What i want to do is this: I have a form with a field where you you can type max. 12 characters or number. But only when you type in 6 characters or number you should be able to see the next form (I add a Redirect in the "On submit" area).
I tried this with a "Load JavaScript" in the "On load" area with this function

function Crew_NumberCheck(el){
  if ( !el.val().match(/^\b\w{6}\b/g) {
    return false;
  } else {
    return true;
  }
}


And in the Designer area in the field "crew_id" ich put following in the Validation/Custon function:
validate['required','%Crew_NumberCheck']


But its not working.
May be someone can help me.
Thanks a lot
Jörg
GreyHead 18 Nov, 2014
Hi Jörg,

If I understand the Help note correctly I think that you only need to put Crew_NumberCheck in the Custom Function box.

Bob
jw-saarow 18 Nov, 2014
Hi Bob,
I set the Custom Function Box to "Crew_NumberCheck".
But its not working.
?
Jörg
GreyHead 18 Nov, 2014
Hi Jörg,

Please post a link to the form so I can take a quick look.

Bob
jw-saarow 18 Nov, 2014
Here comes the link: http://baggageexpress.de/index.php/de/?option=com_chronoforms5&chronoform=Test
GreyHead 18 Nov, 2014
Hi Jörg,

There's a JavaScript error on the page "Uncaught SyntaxError: Unexpected token { baggageexpress.de: 250"

I think that you are missing a ) in the if () line of the function.

Bob
jw-saarow 19 Nov, 2014
Hi Bob,
You are right. Only one ")".
Thanks a lot
Best
Jörg
This topic is locked and no more replies can be posted.