我正在使用 htmx 和 hyperscript,我希望在提交时清除下面表单中的所有输入字段:
<form hx-post="/example" hx-target="#table tbody" hx-swap="beforeend"
_="<what should I write here??>">
<label class="control-label" for="firstNameInput">First Name</label>
<input id="firstNameInput" name="firstName" class="form-control" type="text" required placeholder="John"/>
<label class="control-label" for="lastNameInput">Last Name</label>
<input id="lastNameInput" name="lastName" class="form-control" type="text" required placeholder="Doe"/>
<button class="btn btn-primary">Add User</button>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我尝试<what should I write here??>用例如on submit put '' into <input/>和on submit put '' into <input[value]/>许多其他组合替换,但我无法完成这项工作。
问:提交表单后如何清除所有输入字段?
我正在使用 htmx 和 hyperscript,我希望当表单中所有必需的输入字段都有效时启用“提交按钮”(添加用户)。在这种情况下,必须定义非空名称和有效的电子邮件地址。
<form hx-post="/example" hx-target="#table tbody" hx-swap="beforeend">
<label class="control-label" for="nameInput">Name</label>
<input id="nameInput" name="name" class="form-control" type="text" required placeholder="John Doe"/>
<label class="control-label" for="emailInput">Email</label>
<input id="emailInput" name="email" class="form-control" type="email" required placeholder="john@doe.org"/>
<button _="<what should I write here??>" class="btn btn-primary" disabled>Add User</button>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我应该写什么而不是<what should I write here??>让这种情况发生?