■62303 / inTopicNo.4) |
Re[3]: 【テキストボックス】エンター押下で次のコントロールに移動 |
□投稿者/ たっせい (1回)-(2011/10/02(Sun) 23:38:42)
|
■No62299 (マサヤ さん) に返信 > http://bbs.wankuma.com/index.cgi?mode=al2&namber=40191&KLOG=69 > この話とは違うのでしょうか?
こんなんでしょうか?
<html> <head> <title>Enterキーが押されたら次の項目に進む</title> <style type="text/css"> .num{text-align:right;} </style> <script language="JavaScript"><!-- currentFNo = 0; function nextForm() { if (event.keyCode == 13) { currentFNo++; currentFNo %= document.myFORM.elements.length; document.myFORM[currentFNo].focus(); } }; window.document.onkeydown = nextForm; function display_comma() { var moji = new String(event.srcElement.value); var moji_comma = moji; var comma_delete =/,/g; moji_comma = moji.replace(comma_delete, ""); var format_comma_3 =/(-?\d+)(\d{3})/; var format_comma_6 =/(-?\d+)(\d{3})(\d{3})/; if (moji_comma.length > 3 && moji_comma.length < 7) { moji_comma = moji_comma.replace(format_comma_3, "$1,$2"); }; if (moji_comma.length > 6) { moji_comma = moji_comma.replace(format_comma_6, "$1,$2,$3"); }; event.srcElement.value= moji_comma; }; window.document.onkeyup = display_comma; // --></script> </head> <body>
<form name="myFORM"> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> <input class="num" type="text"><br> </form>
</body> </html>
|
|