我有一个提交表单的函数。我试图在提交按钮被点击后自动刷新。
<fieldset>
<input placeholder="Name" name="name" type="text" tabindex="1" required autofocus>
</fieldset>
<fieldset>
<input placeholder="Email Address" name="email" type="email" pattern="^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$" tabindex="2" required autofocus>
</fieldset>
<fieldset>
<input placeholder="Phone Number" type="tel" name="phno" tabindex="3" size="10" oninvalid="setCustomValidity('Please fill out this field')" required autofocus >
</fieldset>
<fieldset>
<input placeholder="Zip Code" name="zip" type="zip" tabindex="4" size="5" required autofocus>
</fieldset>
<fieldset>
<textarea placeholder="Type your message here...." name="msg" tabindex="5" required autofocus></textarea>
</fieldset>
<fieldset>
<input type="submit" class="submit button" id="submit" value="Submit Message" /> <div id="contact-message"></div>
答案 0 :(得分:0)
在提交功能结束时,您需要这样的内容:
$('form').find("input").val("");
答案 1 :(得分:0)
您需要将<input>
括在带有操作属性的表单中。
<form action="url/to/handle">
<fieldset>
<input placeholder="Name" name="name" type="text" tabindex="1" required autofocus>
</fieldset>
...
<input type="submit" class="submit button" id="submit" value="Submit Message" />
</form>