Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set focus on text box after validation

Status
Not open for further replies.

barathymathialagan

Programmer
Sep 22, 2003
2
CA
I need some help in javascript.

This is my function.


It validate the text, but it is not focusing on the text, after validation. focus goes to the next textbox.

function validatefn(field)
//function is called when the text is changed
{
var dblNum;
var txtText;
var txtMessage;
dblNum = 0.1;
if(!isNaN(field.value)) /* Checks to see if it is a number (isNaN: Not a Number) */
{
dblNum = field .value; /* alerts display message boxes */
}
else
{

alert("Please enter number without commas or dollar signs. ");
}
{

fieldFocus();
field.select();
}
}
This is the textbox

<input type="text" name="txtActRevenue" size="20"
onChange = "validatefn(this);" >

It validate the text, but it is not focusing on the text, after validation. focus goes to the next textbox.

How can I correct?


Barathy
 
Hey,

You seem to have extra { and } in there. But to set a field's focus you would do this
Code:
field.focus();

with field being a reference to the field object for example:
document.formname.txtActRevenue;

Hope that helps.

Later
 
Hey,

You seem to have extra { and } in there. But to set a fields focus you would do this
Code:
field.focus();

with field being a reference to the field object for example:
document.formname.txtActRevenue;

Hope that helps.

Later
 
Sorry,

But the first time I submitted there was an error so I hit back and submitted again. Seems to have submitted twice :}

Later
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top