Startseite › Toolset Professional Support › [Gelöst] Form-validation of text-area: Error-message not showing up
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Tags: CRED API, Toolset Forms
Verwandte Dokumentation:
Dieses Thema enthält 5 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von Shane vor 5 Jahren, 8 Monaten.
Assistiert von: Shane.
I try to check in one of my text-area-fields, if someone posts a link. So I am checking for the string "http" in this text-area. The code works, the form will not be sent, if there is a http in the text. But unfortunately the error-message "Es sind keine Verlinkungen erlaubt" does not show up (please see in my screenshot).
Here is my code:
add_filter('cred_form_validate','my_validation',10,2); function my_validation($error_fields, $form_data) { list($fields,$errors) = $error_fields; if ($form_data['id']==1782) { if (strpos($fields['wpcf-kontakt-nachricht']['value'], 'http') != false) { $errors['wpcf-kontakt-nachricht'] = 'Es sind keine Verlinkungen erlaubt.'; } } return array($fields,$errors); }
Please for help!
Thanks! Diana
Hi Diana,
Thank you for contacting our support forum.
Please check you form on the backend to see if this shortcode is there.
[cred_field field='form_messages' value='' class='alert alert-warning']
If this shortcode isn't added then the message won't show up.
Thanks,
Shane
Hi Shane!
You are right, this block wasn't in my code. But still after implementing it, my warning for the wrong input in my text-area doesn't show up. It seems, that my validation fires after the normal form-validation. Because all of the normal fields validate right after filling in the field. But my custom validation fires not until sending the form.
You can try it out here in my frontend:
versteckter Link
Please click on the red button "Jetzt bewerben".
Then there is the modal-window with my form.
Is there any other way to show this error in the same way like the other errors. They are shown directly after filling in and above the fields which aren't filled out correctly. These errors are adding a new class "has-errors" for the outer-div and there is an attribute data-parsley-error-message="My error-message" for the input itself.
Thanks, Diana
Hi Diana,
You custom validation is fired when the form is being submitted.
The only validation that is fired immediately are the ones for required fields and for special fields such as Email and URL fields.
The only other way I can think of doing this is using JS to validate the fields. Could you explain to me what you are validating for ? this way I can point you in the right direction ?
Thanks,
Shane
Okay, yes please, Shane, for help.
I need to validate a text-area, if there is a link or an e-mail-address in the text.
So checking for the strings "http" and "@" inside the text-area would help.
If there is a string in the text, the error-message should be like "links and email-adresses are not allowed in here."
Thanks again,
Diana
Hi Diana,
I did some checking on this and based on our documentation WYSIWYG fields are validated a little differently, however your code seems to be fine.
For the the verifications above the fields, I believe these are done using the internal verification system. I know that its possible to add the default validation over the fields using Javascript.
Have a look at this link below.
https://stackoverflow.com/questions/36455128/jquery-check-if-input-text-contains-specific-text
This should be able to provide a solution to this for you.
Please let me know what you think of this and I must apologize for the delay in response. If there is anything that is not clear dont be afraid to ask.
Thanks,
Shane