Please help ... form objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    Please help ... form objects

    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="textfield 1"
    onBlur="checkIn teger(this);">

    The function checkInteger(th is) is :

    function checkInteger(pF ield)
    {
    var pattern=/^[0-9]*$/;
    if(!(pattern.te st(pField.value )) & (pField.value!= ""))
    {
    alert(pField.na me + " 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.focu s();

    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

  • kaeli

    #2
    Re: Please help ... form objects

    In article <6e4433100d898c 73b988923b2be5e b14@unlimited.u ltrafeed.com>,
    "Andy" <Please reply to the group> enlightened us with...[color=blue]
    >
    > The function checkInteger(th is) is :
    >
    > function checkInteger(pF ield)
    > {
    > var pattern=/^[0-9]*$/;
    > if(!(pattern.te st(pField.value )) & (pField.value!= ""))
    > {
    > alert(pField.na me + " must must be an integer");
    > }
    > }
    >
    > I want the focus to go back to the field the error was thrown in.[/color]



    pField.focus();



    --
    --
    ~kaeli~
    You can't have everything. Where would you put it?



    Comment

    • Andy

      #3
      Re: Please help ... form objects

      > pField.focus();

      Ahhhhhhh! The only one I didn't. Thanks indeed.
      Andy.

      Comment

      • Mick White

        #4
        Re: Please help ... form objects

        Andy wrote:
        [color=blue]
        > 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="textfield 1"
        > onBlur="checkIn teger(this);">
        >
        > The function checkInteger(th is) is :
        >
        > function checkInteger(pF ield)
        > {
        > var pattern=/^[0-9]*$/;[/color]
        [color=blue]
        > if(!(pattern.te st(pField.value )) & (pField.value!= ""))[/color]

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

        Mick

        [color=blue]
        > {
        > alert(pField.na me + " 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.focu s();
        >
        > 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
        >[/color]

        Comment

        Working...