Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / July 2006



Tip: Looking for answers? Try searching our database.

HELP with Timer...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mel - 31 Jul 2006 14:18 GMT
I have an entry field and a long number "33424JHKJHKJ43432423" as well
as a submit button "FINISHED".

I need to know "HOW LONG" it takes for the user to enter the number
correctly ! if incorrect, it should popup an alert and ask user to
correctly enter the number again and then press FINISHED button

Can someone help me a little Codelet ?

thanks
Paul - 31 Jul 2006 16:39 GMT
> I have an entry field and a long number "33424JHKJHKJ43432423" as well
> as a submit button "FINISHED".
[quoted text clipped - 6 lines]
>
> thanks
Mel, lets see if this is enough to get you started:
<script>
function userKeyDown(){
    if(!arguments.callee.start){
        arguments.callee.start = new Date();
    }
}
function validate(){
    var start = userKeyDown.start;
    if(start) {
        var finished = (new Date()).getTime();
        var diff = finished - start.getTime();
        userKeyDown.start = null;
        alert("User took " + diff + " milliseconds to fill field");
    }else{
        alert("no start time");
    }
    // Validate your form field here
}
</script>

<form>
<input type="text" onkeydown="userKeyDown();">
<input type="button" onclick="validate()" value="finished" />
</form>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.