Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

× Contact Enhanced is a contact component manager created to replace Joomla! core contacts component and add lots of advantages and new features (see Features ) and it offers many plugins and modules for several different purposes,
Product page | Documentation Page

Adding Custom Form Validation To A Field

5 years 1 month ago #24857 by ChartCo
Hi guys,

wondering if there is a configuration option to add a custom error message to a form field via the user-interface.

For example a text field, tel field. Or would this require custom JS to achieve?

Please Log in or Create an account to join the conversation.

5 years 1 month ago #24858 by support
Dear ChartCo,

Which Form Field type are you using?

If you are using a Text Form Field type you can set a Custom Validator under the Text Parameters tab. See screenshot attached.

Please keep in mind the javascript code value represent the field's value. You can also access it via $('#field_alias').val();

Best regards,
Attachments:

Please Log in or Create an account to join the conversation.

5 years 1 month ago #24860 by ChartCo
Hi Douglas,

thank you for your response. So For example I am looking to validate a text field to ensure it only uses a-z characters. I have tested using the following: ($('#name'.val() == /^[A-Za-z]+$/);

Which doesn't seem to work.

Please Log in or Create an account to join the conversation.

5 years 1 month ago #24861 by support
Greetings,

In this case you don't need a Custom Validator. You can use the Alpha Validation instead of Custom.

If you want to use a Custom Validator it would look like this:
(value.match(/^[A-Za-z]+$/));

Best regards,

Please Log in or Create an account to join the conversation.

5 years 1 month ago #24872 by ChartCo
Thanks very much for your feedback, however I would be forced to use a custom validator due to wanting to generate a custom error message. If we are to use the default validator then we aren't able to control the error output to the user.

Thanks again

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback