入力部品の大文字小文字に変換
toUpperCase()やtoLowerCase()を使用して入力フィールドの値などを大文字や小文字に変換することができます。
以下、テキストフィールドに文字を入力し、ボタンを押すと大文字または小文字に変換されます。



以下、ソースです。

<html>
<head>
<title></title>
<script type="text/javascript">
    function upper(){
        document.getElementById('field').value = 
            document.getElementById('field').value.toUpperCase();// 1行で書いてください
    }
    function lower(){
        document.getElementById('field').value =
            document.getElementById('field').value.toLowerCase();// 1行で書いてください
    }
</script>
</head>
<body>
<input type="text" id="field" maxlength="10">
<input type="button" value="大文字に変換" onclick="upper();">
<input type="button" value="小文字に変換" onclick="lower();">
</body>
</html>
スタイルシートで指定
入力時点から大文字にしたい場合や小文字にしたい場合はスタイルシートで指定することができます。
詳しくは こちら を御覧下さい。

Back to top

Information