[Resolved] Validate either mailto or url in custom url field
This thread is resolved. Here is a description of the problem and solution.
Problem:
How to add the URL field as either a URL or mailto field with validation? Or I'd like to offer either option as a "call to action" for content contributors.
Solution:
I believe the validation needs to be done before data is saved, in that case it will needs to be done using custom javascript / jquery code. Our Types fields and WordPress native custom fields does not allow 2 kinds of validation on the same field.
So I recommend you to please use 2 separate fields for this purpose that is the easier approach.
This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Is there a way to offer the URL field as either a URL or mailto field with validation? It seems like I can't do both in one field, but I'd like to offer either option as a "call to action" for my content contributors.
It is for a custom field on a post, not a user field. Some content editors will be using the admin interface but submissions are also being taken through a CRED form.
It seems like I can't use both validation options in one field. Here's a more simple description of what I'm trying to accomplish:
I'd like to have ONE field in which content editors can either put an external URL or an email address. Is it possible to identify which of these two content types are being entered and then validate?
I am going to take over this ticket since Minesh is on vacations, I hope that’s ok. After looking into your request I believe the validation needs to be done before data is saved, in that case it will needs to be done using custom javascript / jquery code. Our Types fields and WordPress native custom fields does not allow 2 kinds of validation on the same field.
So I recommend you to please use 2 separate fields for this purpose that is the easier approach.
Other than that falls into Custom coding & custom development and it is out of support policy (https://toolset.com/toolset-support-policy/). So we recommend to contact Toolset recommended service providers to further discuss the custom approach. We have some recommended list of service providers here if you would like to take a look: https://toolset.com/consultant/