troubleshooting Question

auto submit after x characters

Avatar of waygood
waygood asked on
Fonts TypographyJavaScript
18 Comments2 Solutions2230 ViewsLast Modified:
Hello experts,

I am new to this section, but I have created a basic clocking-in machine using PHP. I have everything setup perfectly but now I want to extend it a little to make it more realistic.
I currently have a form with 1 input text which is auto-selected. The user enters their code and presses enter, which is great.

I am waiting to purchase a card reader (magnetic swipe) and I am looking to get the user to swipe a card and have the form submit automatically once the card has been swiped. IE if the number of characters reaches a certain length. I dont know what format of cards will be used yet, so a solution checking for the first x characters would be sufficient. Any suggestions??

the page in question is below

            <title>Armour Group - TimeClock system...</title>
            <meta http-equiv="Expires" content="Mon, 01 Jan 1996 23:59:59 GMT" />
            <meta http-equiv="Pragma" content="no-cache">
<!-- Original:  Xavier R. ( -->
<!-- Modified:  Benjamin Wright, Editor -->
<!-- Web Site: -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->

<!-- Begin
function clock() {
if (!document.layers && !document.all) return;
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = "AM";
if (hours > 11) amOrPm = "PM";
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;
if (document.layers) {
if (document.all)
pendule.innerHTML = dispTime;
setTimeout("clock()", 1000);
//  End -->

function FormSetFocus()
  if (document.forms.length > 0)
    var TForm = document.forms[0];

    for (i=0;i<TForm.length;i++)
      if ((TForm.elements[i].type=="text")||


      <body onLoad="clock()">
                  <h2>TimeClock System</h2>
                  <span id="pendule" style="background: #000000; color: #80c0c0; font-weight: bold; font-size: 40px; Padding: 20px; border: 20px #ffffff"></span>
                  Please enter your passcode
                  <form name="log" method="post" action="proc_log.php">
                        <input type="password" name="passcode" />
                        <input type="submit" value="CLOCK" />
            <script language="javascript" type="text/javascript">
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 18 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros