Forums

mulitiple client side validation

Liesbeth 25 Sep, 2012
Hi,

I want to use custom client side validation and followed the instructions described here: http://www.chronoengine.com/faqs/2656-how-can-i-add-a-custom-client-side-validation.html

Unfortunately it only works on one field and I want to use it for (almost) all the fields in the form.
I added the script in a load-js-event and changed the "customCheck" (in the function as well as the class name of the field). I tried to put more than one functions in one load-js-event and I tried to use a load-js-event foar each field; both didn't work.

(The standard javascript validation works good on the site.)
GreyHead 26 Sep, 2012
Hi Liesbeth,

YOu can create more than one validation - but each one much have a different function name. customCheck1(), customCheck2() . . . or whatever names you choose as long as they are different from the existing validations.

You can apply any custom validation to more than one form element by adding the class as described in the FAQ.

You can put all of the custom validation code in the same Load JS action.

Bob
Liesbeth 26 Sep, 2012
Thank you,
In one way or another I didn't put the regex in the right way and that did the trick๐Ÿ˜€ .
But now I have my own error message shown up as well as the regular validation text and it looks like this:

This field is required.
Please enter your name.
This field is required.

I just want my own text (Please enter your name.), like I added in the load js. Disabling jsvalidation in the form settings doesn't seem to matter.
GreyHead 26 Sep, 2012
Hi Liesbeth,

Do you still have the Required box checked on the element Validation tab?

Bob
Liesbeth 26 Sep, 2012
Hi Bob,

Thank you; I unchecked the required box, but then it says:

This field is required.
Please enter your name.

Liesbeth
GreyHead 26 Sep, 2012
Hi Liesbeth,

Then there is probably still another validation on that form element. I can't tell where it is set though :-(

Bob
GreyHead 26 Sep, 2012
Hi Liebeth,

If I look at the Form HTML the Antal input has class="validate['required','%aantal'] validate['number']" with an error message for each of the validations which is correct.

The question is where are the two extra validations being set?

Bob
Liesbeth 26 Sep, 2012
Hi Bob,

What do you mean with the "two extra validations"; I don't understand where you are referring to.
Does every has to have a validation?

Liesbeth
GreyHead 26 Sep, 2012
Hi Liesbeth,

You have three validations set: 'required', '%aantal' and 'number'. Each of these will add an error message if the validation fails.

Bob
Liesbeth 26 Sep, 2012
Okay, thank you, I understand it.
But when I delete 'required' and 'number', the validation doesn't work at all.๐Ÿ˜Ÿ
GreyHead 27 Sep, 2012
Hi Liesbeth,

It looks as though you now have this working correctly?

Bob
Liesbeth 27 Sep, 2012
Yes, I temporarely "solved" it by deleting the text "this field is required" from the language file.
GreyHead 27 Sep, 2012
Hi Liesbeth,

You still have a 'required' validation set on the inputs - that's why the 'required' error shows, or would show id you hadn't removed the message.

Bob
Liesbeth 27 Sep, 2012
Hi Bob,

Yes, I know, but, as I said in an earlyer post: the validation does'nt work at all when I remove 'requiered' from the field class.

So this works: validate['required','%aantal']
And this doesn't work: validate['%aantal']
GreyHead 27 Sep, 2012
Hi Liesbeth,

It looks to me as though it works OK. It shows the error if there is an entry in the input that is not a number. It doesn't show an error if the input is empty because it it no longer required.

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