Forum Moderators: open

Message Too Old, No Replies

How to go to a specific field?

VERY beginner question, I apologize

         

eikelein

5:32 pm on Jan 6, 2005 (gmt 0)

10+ Year Member



Hi;

after over two hours of searching in vain I finally solicit help.

On an input field I have an onChange="InputOK(this)" event handler that gets triggered when users move away after changing the contents of the field. InputOK does some tests.

If the test is okay all is well

BUT if the test fails I need to

reset the value to 0 (zero); no issue and
keep the focus on/in this field, actually suppressing/reversing the effect of whatever user action took the focus away.

My "problem" is that I just can't find any clue on how to do keep this field "focused".

Somewhere in my memory is a "setFocus" or the like but all my googling and searching on tutorial sites lead to VB only - and I have to do Javascript.

TIA for any pointer or hint on where to look or how to get it done.

adni18

9:47 pm on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



set the value to zero:

function yolk(zeroin)
{
zeroin.value="0";
}

focus the value:

function yolk(zeroin)
{
zeroin.focus();
}

adni18

9:49 pm on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you need to undo what the user did, try something like:

var yolk="";
function strFocus(o)
{
yolk=o.value;
}

function stir(p)
{
if(/* (Your conditions) */)
{
p.value=yolk;
}
}

<input onFocus="strFocus(this)" onBlur="stir(this)" type="text">

eikelein

3:38 am on Jan 7, 2005 (gmt 0)

10+ Year Member



Thank you VERY much!