Jump to content

Focus of text field changes when field is full?


Roble

Recommended Posts

Hello,

I'm working on my dad's insurance website, and I was making the quotes form. He's told me that he wants the licence number to be entered into 3 text fields, each having a maxlength of 5. But he wants the fields so that when the first text field is filled out, it will go on to the second, and then on to the third after that. He wants it to be automatic, so his potential clients dont have to hit tab. I've tried doing this with JS, but to no avail. Wondering if this can be done using PHP? If not can you give me a better JS script then the one I found? Much appreciated.
well this time i found it for u create a function on top of page and it would be like

[code]
<FORM NAME="cc">
<INPUT TYPE="text" name="num1" size="5" onKeyUp="check()"><BR>
<INPUT TYPE="text" name="num2" size="5" onKeyUp="check2()"><BR>
<INPUT TYPE="text" name="num3" size="5" onKeyUp="check3()"><BR>
<INPUT TYPE="submit" VALUE="Click to Send" NAME="go">
</FORM>


<?php
function check()
{
var letters = document.cc.num1.value.length +1;
if (letters <= 5)
{document.cc.num1.focus()}
else
{document.cc.num2.focus()}
}

function check2()
{
var letters = document.cc.num2.value.length +1;
if (letters <= 5)
{document.cc.num2.focus()}
else
{document.cc.num3.focus()}
}

function check3()
{
var letters = document.cc.num3.value.length +1;
if (letters <= 5)
{document.cc.num3.focus()}
else
{document.cc.go.focus()}
}
?>
[/code]

sorry jeremy i proved u wrong (i hate doing that)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.