[英]How to check if a text input string on change has an Uppercase letter Javascript
Is there a way to check if a text input, on change, has an uppercase letter, in the string using just javascript (or in combination with regex)?有没有办法检查文本输入是否在更改时仅使用 javascript(或与正则表达式结合)在字符串中具有大写字母?
For example:例如:
const passwordInput = document.querySelector("#password");
passwordInput.addEventListener("change", e => {
if (e.target.value does not contain an uppercase letter) {
console.log("Must contain an uppercase letter.")
}
})
if (e.target.value == e.target.value.toLowerCase()) { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.