Forums

Custom messages for error validation

Fredd 17 Jun, 2015
Hello,

I would like to add a custom error message on a field (for example e-mail).
I would not do it by adding text in title field for user can see this text when overing the field.

I am trying doing this by adding a "Load JavaScript" module on the "on load" bloc (on the top of it).

Then, in th JS Code field, I am adding this :
<?php 
jQuery.gvalidation.errors.required = "test required custom message"; 
jQuery.gvalidation.errors.email = "test email message"
?>
But... it is not working...

Could you please help me ?

Thank you in advance.
GreyHead 18 Jun, 2015
Hi Fredd,

The second line is missing a ; at the end. Is that the problem here?

Bob
Fredd 19 Jun, 2015
Hello Bob,

Thank you for your reply.
I have added the ";" at the end, but I still have the by default message : "Please enter a valid email."...
GreyHead 19 Jun, 2015
Hi Fredd,

And remove the <?php ?> tags as this isn't PHP - sorry, I missed those before.

Bob
Fredd 19 Jun, 2015
Hi Bob,

It worse when i remove the PHP tags : I can't see the tooltip anymore, nore the red dotted for "requires fields"...
An when I send the form, I got the error message (erro.png).

Here is my code :

jQuery.gvalidation.errors.required = "test required custom message";
jQuery.gvalidation.errors.email = "test email message";
GreyHead 20 Jun, 2015
1 Likes
Hi Fredd,

I just tested [url=http://j3.greyhead.org/index.php?option=com_chronoforms5&chronoform=test_custom_validation_message]here[/URL] and it appears to be working correctly.

I copied and pasted your code into a Load JavaScript action before the HTML (Render form) action in the On Load event of the form.

Bob
Fredd 22 Jun, 2015
Hi Bob,

Well, it appears that it was due to the CF component version !
I update from Chronoforms_V5.0_Component_RC5 to Chronoforms_V5.0.9_Component and it seems to work !

I am going to carry on my tests to see if everything is ok.

Thank you very much for your help.
GreyHead 22 Jun, 2015
Hi Fredd,

That makes sense - Max must have added this feature it in a later version.

Bob
Fredd 23 Jun, 2015
Hello Bob (me again !),

Could you tell me how to add other fiel warning ?
For example, I have other fields like "name", "surname", "phone", or even an email check (email control field that must be exactly the same as the "email" field above.

Thank you very much.
GreyHead 23 Jun, 2015
1 Likes
Hi Fredd,

The gvalidation.errors.email message is only applied when you are checking for a valid email so I guess the others aren't the same.

You can edit the validation language file if you need to or add custom messages in the Title box of the input element.

Bob
Fredd 23 Jun, 2015
Great !
It works by using : jQuery.gvalidation.errors.confirm="my text";
Thank you !

Euh, one last thing if I can : is it possible to put multi fields in "dynamic subject" (i have tested with "name, surname" my static subject) but it doesn't work...😢
Fredd 06 Jul, 2015
Answer
Ok Bob,

Thank you for your reply.
GreyHead 06 Jul, 2015
1 Likes
Hi Fredd,

Sorry, I missed the second question :-(

Please see this FAQ

Bob
Fredd 06 Jul, 2015
Hi Bob,

No problem : It works GREAT !
Thank you again 😀
This topic is locked and no more replies can be posted.