大文字・小文字・全角・半角変換
- <!DOCTYPE html>
- <html lang="ja">
- <head>
- <meta charset="UTF-8">
- <title>大文字・小文字・全角・半角変換</title>
- <body>
- <h1>大文字・小文字・全角・半角変換</h1>
- <script type="text/javascript">
- // 英数字を半角変換
- function changeHalfChar()
- {
- str = document.getElementById("InputText").value
-
- HalfChar = str.replace(/[A-Za-z0-9]/g, function(s)
- {
- return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
- });
-
- alert(HalfChar);
- }
-
- // 英数字を全角変換
- function changeFullChar()
- {
- str = document.getElementById("InputText").value
-
- FullChar = str.replace(/[A-Za-z0-9]/g, function(s)
- {
- return String.fromCharCode(s.charCodeAt(0) + 0xFEE0);
- });
-
- alert(FullChar);
- }
-
- // 英語を小文字変換
- function changeLowerChar()
- {
- str = document.getElementById("InputText").value
-
- LowerChar = str.toLowerCase();
-
- alert(LowerChar);
- }
-
- // 英語を大文字変換
- function changeUpperChar()
- {
- str = document.getElementById("InputText").value
-
- UpperChar = str.toUpperCase();
-
- alert(UpperChar);
- }
-
- </script>
- <input type="text" value="" id="InputText" /><br />
- <input type="button" value="英数字を半角変換" onclick="changeHalfChar()" />
- <input type="button" value="英数字を全角変換" onclick="changeFullChar()" />
- <input type="button" value="英語を小文字変換" onclick="changeLowerChar()" />
- <input type="button" value="英語を大文字変換" onclick="changeUpperChar()" />
- <div style="font-size:10pt;text-align:right;margin-top:0.5em;">
- <a href="//tips.recatnap.info/" target="_top">PCスキルの小技・忘却防止メモ</a> -
- <a href="//tips.recatnap.info/wiki/" target="_top">PCスキルの小技・忘却防止メモのまとめ(wiki)</a>
- </div>
- <div style="font-size:10pt;text-align:center;margin-top:0.5em;padding:0.5em;border-top:1px solid #ccc;">
- Copyright © 2009 by PCスキルの小技・忘却防止メモ. All rights reserved.
- </div>
- </body>
- </html>