Please help ... form objects

A

Andy

Hi

Using IE6.

I have a textbox in a form. The form is called 'form1' and the textbox is
called 'textfield1'. I have an onBlur event on the textbox to check its
contents is an integer thus: <input type="text" name="textfield1"
onBlur="checkInteger(this);">

The function checkInteger(this) is :

function checkInteger(pField)
{
var pattern=/^[0-9]*$/;
if(!(pattern.test(pField.value)) & (pField.value!=""))
{
alert(pField.name + " must must be an integer");
}
}

I want the focus to go back to the field the error was thrown in. I have
tried all sorts of methods but the only one that seems to work is directly
refencing the textfield1 object like this:
document.form1.textfield1.focus();

I would like to do something like:
var oField=pField;
document1.form1.oField.focus();

I keep getting document.form1.oField has no properties. Whats wrong?

Many thanks for looking and any help.
Andy
 
K

kaeli

The function checkInteger(this) is :

function checkInteger(pField)
{
var pattern=/^[0-9]*$/;
if(!(pattern.test(pField.value)) & (pField.value!=""))
{
alert(pField.name + " must must be an integer");
}
}

I want the focus to go back to the field the error was thrown in.



pField.focus();



--
 
M

Mick White

Andy said:
Hi

Using IE6.

I have a textbox in a form. The form is called 'form1' and the textbox is
called 'textfield1'. I have an onBlur event on the textbox to check its
contents is an integer thus: <input type="text" name="textfield1"
onBlur="checkInteger(this);">

The function checkInteger(this) is :

function checkInteger(pField)
{
var pattern=/^[0-9]*$/;
if(!(pattern.test(pField.value)) & (pField.value!=""))

Doesn't make sense: Unbalanced brackets
& is not the same as &&

Mick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top