javascript自动转换大小写

时间:2024-10-20 19:38:02

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 大小写 </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function a(){
  document.getElementById("test").value = document.getElementById("test").value.toUpperCase();
}
function b(){
  document.getElementById("test2").value = document.getElementById("test2").value.toLowerCase();
}
</script>
<BODY>
在这里输入小写,会自动转为大写:<input type=text id=test onkeyup="a()"><br/>
在这里输入大写,会自动转为小写:<input type=text id=test2 onkeyup="b()">
</BODY>
</HTML>