我正在建立一个搜索栏,我想被禁用,除非用户输入的东西。感谢任何帮助,使这项工作。
这是我的handlebars代码:
<div class="searchWrapper">
<form action="/founduser" method="POST" class="searchBar">
<input type="hidden" id="groupid" name="groupid" value={{this.groupid}}>
<input type="text" name="searchBar" id="searchBar" placeholder="Enter the user's email ID"
value="{{this.term}}" />
{{!-- <i class="fas fa-search"></i>
<input type="submit" value="" id="submit"> --}}
<button type="submit" class="btn-search" id="user-search-btn"><span class="icon search"
disabled></span></button>
</form>
</div>我正在运行一个JS检查来替换
const searchButton = document.getElementById('user-search-btn');
const check = () => {
if (searchButton !== "") {
searchButton.disabled = false
} else {
searchButton.disabled = true
}
}
searchButton.onkeyup = check我哪里错了?
发布于 2021-05-01 19:02:37
抱歉,我知道我错在哪里了。在我的代码中,我检查searchButton是否为空,但是我应该做的是检查<input type="text" name="searchBar" id="searchBar" placeholder="Enter the user's email ID" value="{{this.term}}" />中的值。
https://stackoverflow.com/questions/67320375
复制相似问题