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>