Skip Navigation

[Resolved] Ajax Lookup in Number Field

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2627587

Tell us what you are trying to do? I would like for a member to type a number (in a certain range) and the system to check whether that number is available. For example, the member is interested in purchasing number 1234 by entering this value in the cred form, the system needs to confirm availability.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2627635

Hi,

Thank you for contacting us and I'd be happy to assist.

There is no built-in field available in the forms that can be used for the Ajax Lookup. But, there is a workaround that can be used.

You can register a new custom post type 'Numbers' and add a form that creates a new 'Number' post.

In that form, you can include a custom validation function attached to the 'cred_form_validate' hook, that ensures that a number post with the same 'title' can't be created again.
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate )

This way if the user will try to create a number post with the title that is already taken, the validation message will show, asking to enter a different number.

You'll find an example of a similar validation function, in this forum reply:
https://toolset.com/forums/topic/prevent-duplicate-post-titles-from-being-created/#post-1368925

regards,
Waqar