Notes Javascript Focus Problem

I have a java validator that is very simple, if the field contains values not in the validator, it clears the field … problem is, it also moves the cursor focus to the next field.

I need the focus to be in the same field…

also need to make sure the field value default is unchanged.

Can anyone help me with this…

I know NOTHING about JS…

The onBlur or onChange event has same effect.

the code is as follows…

In the header —

var numb = “0123456789,”;

function res(t,v){

var w = “”;

for (i=0; i < t.value.length; i++) {

x = t.value.charAt(i);

if (v.indexOf(x,0) != -1)

w += x;

}

t.value = w;

}

In the EVENT —

res(this,numb)

it does what is supposed to do in that it will not allow entry of any character not in the var value… but the focus and default value are my big problem…

Any help would be greatly appreciated.

Subject: Notes Javascript Focus Problem

Not sure I understand… the field I want to return to is a Notes field called LSHousingRent…

How would I structure the code to return to that field after the

OnBlur event? Should I put in the same code with the validator? or in an event for the next field?

Thanks again

Subject: RE: Notes Javascript Focus Problem

onEvent code should return a value. true (the JavaScript boolean value) means that the event can proceed, false means that it cannot. Adjust your call to the validation code to read:

return res(param1, param2)

and make sure that res() returns false when validation fails, and true when validation succeeds.

Subject: RE: Notes Javascript Focus Problem

Field Event Change nearly is there…

Hi Stan… I added … return res(this,numb) in the event.

Now it cleans up the field as its supposed to, but instead of returning focus to field, focus is gone. I need to reset focus and the default value of 0 to the field in the validation event. If the field does validate correctly, it does move to the next field and focus.

Any chance you can help me with that. If I get this working right it I will post it… a lot of people seem to have this problem. This routine works good and is easy to understand.

Subject: RE: Notes Javascript Focus Problem

The code should probbly go into the onblur event rather than the onchange, since losing focus is what you’re trying to prevent. Setting the default value is just a matter of adding this:

argument[0].value = ;

just before the “return false;” line. Remember, the first argument to the function call is the field object, so you can refer to it using the arguments collection.

Subject: Notes Javascript Focus Problem

To set focus on a field use document.formname.fieldname.focus().

in your case it will be t.focus();

Regards

Litty Joseph