Skip Navigation

[Résolu] Bug: bad input on repeat password field trigger JS error

This support ticket is created Il y a 8 années. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

Marqué : 

This topic contains 3 réponses, has 2 voix.

Last updated by Luo Yang Il y a 8 années.

Assisted by: Luo Yang.

Auteur
Publications
#374712

Note: This is not a support request, it's a bug report along with the fix. Please escalate this to the DEV team.

I made a CRED user form for new user registration, with a "Repeat password" field.
When a user submits a wrong password pair (different passwords) a javascript (jQuery) error is triggered because of the following snippet injected by CRED:

<script language="javascript">
            jQuery(document).ready(function(){jQuery('[data-wpt-name="user_pass"]:first').parent().insertAfter('[data-wpt-name="user_pass"]:first');jQuery('[data-wpt-name="user_pass2"]:first').parent().insertAfter('[data-wpt-name="user_pass2"]:first');});
            </script>

I tracked down the problem to file cred-frontend-editr/embedded/classes/CredForm.php, inside function getFieldsErrorMessagesJs (around line 3555 in my version of the file).
The offending code is the following:

$js.='jQuery(\'[data-wpt-name="' . $id_field . '"]:first\').parent().insertAfter(\'[data-wpt-name="' . $id_field . '"]:first\');';

which clearly is wrong, as it tries to insert the parent of an element after the element itself, without detaching it from the DOM.

Luckily two lines above there was a commented alternate version, which seems to work as expected:

$js.='if (jQuery(\'[data-wpt-name="' . $id_field . '"]:first\').length) jQuery("#lbl_' . $id_field . '").detach().insertAfter(\'[data-wpt-name="' . $id_field . '"]:first\');

I switched the two lines (uncommented the first and commented the second) and it looks fine.

I hope you will update this in the next CRED version.

Thank you.

#374842

Dear Francesco,

Thanks for the feedback, I have been able to duplicate same problem, and put it into our to-do list, our developers will take care of it.

#378813

Thanks. Is there an ETA for the release of this fix? It looks that in the latest release (1.5.2) the problem is still present.

#379063

Here is the feedback from our developers:
1) it is fixed in future version of CRED 1.6, which is still in development status
2) currently, you can try the workaround in Erratas:
https://toolset.com/errata/password-field-not-appearing-field-validation-triggered/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.