简体   繁体   English

如何检查更改时的文本输入字符串是否具有大写字母 Javascript

[英]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.

相关问题 如何检查更改时的文本输入字符串是否具有小写字母 Javascript - How to check if a text input string on change has a Lowercase letter Javascript 如何使用 Javascript 检查更改时的文本输入字符串是否有数字 - How to check if a text input string on change has a number using Javascript 在JavaScript中将字符串中的第一个字母更改为大写 - Change first letter in string to uppercase in JavaScript 如何使用JavaScript函数将表单输入文本更改为大写 - How to change a form input text to uppercase using a JavaScript function 如果数据属性(HTML)=== javascript 中的输入文本,如何更改已写入输入的每个字母的 javascript 颜色? - How can I change color in javascript for each letter which has been written into an input if data attribute(HTML) === input text in javascript? 如何检查 javascript 中的字符串是否既有字母又有数字 - How to check is string has both letter and number in javascript 如何使用 JavaScript 测试字符串中的字母是大写还是小写? - How can I test if a letter in a string is uppercase or lowercase using JavaScript? 如何将 JavaScript 中的字符串首字母大写? - How do I make the first letter of a string uppercase in JavaScript? 检查是否所有单词首字母大写 JavaScript - Check if all words first letter uppercase JavaScript JavaScript 在涉及大写字母时不删除文本 - JavaScript not removing text when a uppercase letter involved
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM