[javascript]小寫轉大寫(onkeypress,onkeyup,onkeydown,toUpperCase)

  • 10557
  • 0
  • 2012-06-01

摘要:[javascript]小寫轉大寫


            //小寫轉大寫
            function Little2Big(id) {
                document.getElementById(id).value = document.getElementById(id).value.toUpperCase();
            }

上面是javascript


 <asp:TextBox ID="txtKeyup" runat="server"></asp:TextBox>

上面是html設定項目


Me.txtKeyup.Attributes.Add("onkeyup", "Little2Big('" & txtKeyup.ClientID & "')")

最後加入onkeyup事件就好嚕~請注意不要弄成onkeypress喔!!!那是會失敗的!!