Skip Navigation

[Resolved] How to validate fields in form

This support ticket is created 7 years, 4 months 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 7 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#554129
pic2.PNG
Pic1.PNG

hello

I am Create one website in that website More than One registration Form.

In that Form field are as follows .

field actual required actual
1. Name Only accept String It accept Number and String
2. Contact Number Only accept Number It accept Number and String
3. Resume Only accept word File Or PDF Format It accept all format( like video, Image)

How to validate this all fields??????

Link .
1. hidden link
2. hidden link

Please show attachment Screenshots to more information.

Thanks,
Dharanendra

#554176

In Toolset, when you create CRED user Forms, no Phone Number is added.

Hence, you use either a Custom User Field or took control over another (3rd Party) field with CRED.

To have a Field validated in the way you want, I suggest to head to Toolset > User Fields and add a Number Custom Field.
That will not allow any other characters but numbers.

Or, you can use an API hook of CRED to validate that Field:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

Name, Nickname, Username all accept by default strings and numbers, and that is just WordPress default behaviour, we cannot change that.
What you can do is use as well a CRED API validation that hooks your Custom Code validation to the form:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

Note that, CRED API is a set of hooks that allow you to hook your custom code to the form, at the right moment.
The API does not provide custom code solutions, this means, the validation itself must be coded by you, or another programmer, according PHP and WordPress coding standards.

The API just is a hook, that allows you to fire your own code at the right moment of form submit.

To validate a Upload (file) Field, you can use the exact same hook.

Please let me know if you have any other issue with CRED!