当サイトはユーザー体験を改善するためのメンテナンスを実施中に機能が制限される予定です。記事を読んでもあなたの問題が解決せず質問をしたい場合は、Twitter の @FirefoxSupport、Reddit の /r/firefox で、サポートコミュニティが皆さんを助けようと待機しています。

Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

FF – required input validated no matter execution runs in handler

more options

I have some background form submission implemented. Similar to

    form.onsubmit = function XY(e) { e.prevenDefault(); … }

In form there is (similar) input

    <input type="text" name="someName" required="required" class="toBeCleared"/>

Then there is (similar) JS.

    if(e.currentTarget.elements["someName"].className === "toBeCleared") {
      e.currentTarget.elements["someName"].value = '';
    }

Everything works as expected except that in FF after all work is done the field is marked with red color as not validated (since it is empty and required).

Return false, true from body of handler has no effect on this.

I have some background form submission implemented. Similar to <pre><nowiki> form.onsubmit = function XY(e) { e.prevenDefault(); … }</nowiki></pre> In form there is (similar) input <pre><nowiki> <input type="text" name="someName" required="required" class="toBeCleared"/></nowiki></pre> Then there is (similar) JS. <pre><nowiki> if(e.currentTarget.elements["someName"].className === "toBeCleared") { e.currentTarget.elements["someName"].value = ''; }</nowiki></pre> Everything works as expected except that in FF after all work is done the field is marked with red color as not validated (since it is empty and required). Return false, true from body of handler has no effect on this.

この投稿は cor-el により に変更されました

すべての返信 (2)

more options

Maybe remove the required attribute or put some dummy content in it after you have confirmed that the data is valid?

Try to ask advice at the Stack Overflow forum site.

more options

cor-el said

Maybe remove the required attribute or put …

I was just about to get info if it is known bug, feature or whatever else there can be known about it.

I can invent some workaround anyway.

この投稿は fire-in-the-mine-hole により に変更されました