Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you mean javascript, you could go with the "advance to next input" method:</p> <p>Here's the HTML:</p> <pre><code>&lt;form id="ccform" action="cc_submit.php" method="post"&gt; &lt;fieldset id="ccnumber"&gt; &lt;input id="firstset" type="text" maxlength="4" /&gt; &lt;input id="secondset" type="text" maxlength="4" /&gt; &lt;input id="thirdset" type="text" maxlength="4" /&gt; &lt;input id="fourthset" type="text" maxlength="4" /&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>And here's the JS:</p> <pre><code>var ccfields; function moveToNext(e) { var field = e.currentTarget; var chars = field.value.length; var setnumb = Number(field.id.substr(3,1)) - 1; if(chars &gt;= 4 &amp;&amp; setnumb &lt; 3) { ccfields[setnumb + 1].focus(); } } window.onload = function() { ccfields = document.getElementById("ccnumber").getElementsByTagName("input"); for (var i = 0; i &lt; ccfields.length; i++) { ccfields[i].onkeyup = moveToNext; } }; </code></pre> <p>Of course, you will want to add a function that checks for non-numbers and a function for taking the four fields and merging them into one string to pass back to the form. It also isn't a bad idea to use a js library like Jquery to ensure that events are handled the same way and simplify traversing through the inputs so you can use attributes like "name" without any confusion.</p> <p>But generally, if people see 4 fields, it makes it easier to type in their number, and for those visitors who think "ah nuts, I have to use my mouse for each number" they are (or at least I am) pleased that the page is smart enough to know to move to the next field.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload