搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

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于修改