This thread is resolved. Here is a description of the problem and solution.
Problem:
Validation and Required field option should work at once in CRED User form for native WP Fields (e.g. Last Name), same as builtin CRED form style.
Solution:
1. Add this code in your theme’s or child theme’s functions.php file:
==> Make sure to replace 'last_name', 'adresse' with your field slugs on line #3
==> You can modify the message text as needed in above code on line #7.
I'm building a Cred user form and have standard user fields (like last_name) and specific user fields created with Types.
Now, I want all fields to be required in the form. For all new created fields, no issue, but with the standard "last_name" field, it is not considered as required in the form.
Here is the code I'm using :
[cred_field field='last_name' post='user' value='' urlparam='' class='form-control' output='bootstrap' required='true']
Let me know if there is something to do on this.
Regards
Pat
Thank you for getting in touch with us. Yes, you can make any field required using this jQuery code. Please add this in your User CRED form >> JS editor section:
Thanks for the info. This is working, but the issue is that the validation is not done in the same time that the other ones. The last_name validation came first and then, if you fill the field, then you have the other validations that are display in error if the fields are empty.
Is there a way to add a validation for last_name that is managed the same way than for the other fields?
Regards
Pat
1. I would suggest to add this style to all the fields you want to make required, this way it will show consistent required message and in correct order too:
I have tried to place all needed validations with your jquery solution, but this is not working. Here is what I placed in the jquery tab :
jQuery( document ).ready(function() {
Okay, I need to look into your site, please provide temporary access (WP-Admin and FTP Login info) to your staging site.
Your next answer will be private which means only you and I have access to it.
=== Please backup your database and website ===
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
✙ Please add the Links to the [CRED Form] Edit Screen and [Page] where you have inserted this Form.
Hi Noman,
Thanks for the feedback.
I just tested it and I'm not sure of the result :
The validation now works field by field, which means, you have to click onthe submit button to see the first notification, then, fill the required field and press again on the submit button to have the second notification which is displayed.
I would prefer to have the same way of working than the standard Cred validation (ie : the first time you press on the submit button, you have all needed required fields that are highlighted).
I am able to find another workaround. I have removed js validation and added it using php code and cred filter hook, now it works same way as builtin cred style: hidden link
I have added this code in theme’s functions.php file, you can modify the message text as needed: