如果用户在输入框中输入的字符超过20个,下面的JavaScript代码将刷新html页面。但是,我不希望输入框的内容被清除,我希望即使用户验证失败,它们也会留在输入框中。除了在表单中使用OnSubmit之外,还有什么方法可以避免页面清除数据吗?
<form >
Enter your e-mail address: <input type="email" name="email" id="email">
Enter your Name/Username : <input type="text"
我使用这个JS尝试在用户单击clear按钮时将输入框的文本设置为空
// This code is not inside of the clearText function
var input = document.getElementById("input");
// this code is inside of the clearText function
input.innerHTML = "";
下面是我用于输入框和清除按钮的HTML:
<input id="input" type="text">
<