转载自品略图书馆 http://www.pinlue.com/article/2019/03/2920/108481368500.html
一个小写转大写的JS:
Javascript代码
document.getElementById("output").value=document.getElementById("input").value.toUpperCase();
document.getElementById("output").value=document.getElementById("input").value.toUpperCase();
大写转小写
Javascript代码
document.getElementById("TextBox1").value=document.getElementById("TextBox2").value.toLowerCase();
例:实时将输入内容,小写字母转为大写字母,即使复制粘贴内容,也可以实时转换。
<tr>
<td valign="middle">
<input type="text" style="width:200px" id="aa" name="aa" maxlength="22" onkeyup="setUpperCase(this);" oncontextmenu="window.event.returnValue=false"/>
<span style="color:red;" ></span>
</td>
</tr>
<script type="text/javascript">
function setUpperCase(obj){
var a=obj.value;
var b=a.toUpperCase();
obj.value= b ;
}
</script>
本文介绍了一种使用JavaScript实时将输入内容的小写字母转换为大写字母的方法,同时也提供了将大写字母转换为小写字母的代码示例。通过简单的HTML和JavaScript结合,可以实现文本框中输入内容的实时大小写转换。
582

被折叠的 条评论
为什么被折叠?



