“请填写所需字段” - 隐藏的字段阻止了我的提交

发布于 2025-01-21 12:20:17 字数 732 浏览 1 评论 0原文

我有一个带有BuddyBoss的WordPress页面。 PageBuilder是Elementor Pro。插件Buddyboss为您提供了Facebook类似功能。在Buddy Boss中,评论帖子& co没问题,但是如果我在Buddyboss系统之外有帖子,我将无法提交评论。为了提交我的评论,必须填写一个隐藏的领域。 代码行

如果我放了一个用ID来定位区域的脚本并尝试删除它不起作用。如果我手动删除它,我可以提交。 你们有什么想法吗?

如果没有隐藏我的文本方面的CSS,它看起来像这样:

<textarea 
  id="aad669143d1a2b175fb447cb79a28f4b" 
  aria-label="hp-comment" 
  aria-hidden="true" 
  name="comment" 
  autocomplete="new-password" 
  style="" 
  tabindex="-1" 
  class="error" 
  aria-describedby="aad669143d1a2b175fb447cb79a28f4b-error" 
  aria-invalid="true">
</textarea>

I have a wordpress page with buddyboss installed. The Pagebuilder is Elementor pro. The Plugin Buddyboss gives you Facebook like functions. In buddy boss, it's no problem to comment on posts &co, but if I have a post outside of the buddyboss system, I can't submit my comment. There's one hidden field that must be filled in order to submit my comment. Line of code

If I put in a script that targets the area by its Id and tries to delete it, it won't work. If I delete it manually, I can submit it.
Do you guys have any idea?

Without the CSS that hides my Textarea it looks like this:

<textarea 
  id="aad669143d1a2b175fb447cb79a28f4b" 
  aria-label="hp-comment" 
  aria-hidden="true" 
  name="comment" 
  autocomplete="new-password" 
  style="" 
  tabindex="-1" 
  class="error" 
  aria-describedby="aad669143d1a2b175fb447cb79a28f4b-error" 
  aria-invalid="true">
</textarea>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

汹涌人海 2025-01-28 12:20:17

根据您在评论中发布的代码,事实证明,针对aria-label的目标确实可能是您需要的。为了删除它,您将修改代码如下:

var element_to_remove = document.querySelector('[aria-label="hp-comment"]');
element_to_remove.remove();

第一行基于属性aria-label及其值hp-comment,第二行> Line从HTML树中删除它(应在所有现代浏览器中工作;或者,您可以尝试parentnode概述的方式)。

您可以使用此扩展代码片段尝试一下:

var element_to_remove = document.querySelector('[aria-label="hp-comment"]');
console.log(element_to_remove.id); // the id is logged
element_to_remove.remove(); // remove the element
element_to_remove = document.querySelector('[aria-label="hp-comment"]'); // nothing here
console.log(element_to_remove); // --> null is logged
<textarea id="aad669143d1a2b175fb447cb79a28f4b" aria-label="hp-comment" aria-hidden="true" name="comment" autocomplete="new-password" style="" tabindex="-1" class="error" aria-describedby="aad669143d1a2b175fb447cb79a28f4b-error" aria-invalid="true">
</textarea>

(当然,第2、4和5行只是为了演示而不是真正必要的。)

Based on the code you posted in your comment, it turns out that targeting the aria-label might indeed be what you needed. In order to remove it, you would modify your code as follows:

var element_to_remove = document.querySelector('[aria-label="hp-comment"]');
element_to_remove.remove();

The first line finds the element based on the attribute aria-label and its value hp-comment, the second line removes it from the HTML tree (which should work in all modern browsers; alternatively, you could try the parentNode way you outlined).

You can try it using this extended code snippet:

var element_to_remove = document.querySelector('[aria-label="hp-comment"]');
console.log(element_to_remove.id); // the id is logged
element_to_remove.remove(); // remove the element
element_to_remove = document.querySelector('[aria-label="hp-comment"]'); // nothing here
console.log(element_to_remove); // --> null is logged
<textarea id="aad669143d1a2b175fb447cb79a28f4b" aria-label="hp-comment" aria-hidden="true" name="comment" autocomplete="new-password" style="" tabindex="-1" class="error" aria-describedby="aad669143d1a2b175fb447cb79a28f4b-error" aria-invalid="true">
</textarea>

(Of course, the lines 2, 4 and 5 are just for demonstrating and not really necessary.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文