当用户在 vanilla Javascript 中的文本框中输入小于限制时,如何显示警报。
let input = document.getElementById('input') // alerts at 6 characters if (input.value.length > 5) { alert('Your alert'); }
<input type="text" id="input">
我通过
<input type="text" onblur="if (this.value.length < 5){alert('Your alert'); }" >
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.