OnSubmit using two script validations

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

    OnSubmit using two script validations

    I cannot figure out how to complete two script validations onsubmit. Only
    the first one listed runs. If anyone knows how to do this, please help.

    --
    Olivia Towery


  • Tom de Neef

    #2
    Re: OnSubmit using two script validations

    "Olivia Towery" <timwebs@adelph ia.netwrote
    >I cannot figure out how to complete two script validations onsubmit. Only
    the first one listed runs. If anyone knows how to do this, please help.
    >
    onsubmit=valida te1(),validate2 ()
    or
    onsubmit=valida te1()&&validate 2()

    Tom


    Comment

    • Evertjan.

      #3
      Re: OnSubmit using two script validations

      Olivia Towery wrote on 19 apr 2008 in comp.lang.javas cript:
      I cannot figure out how to complete two script validations onsubmit.
      Only the first one listed runs. If anyone knows how to do this,
      If you mean input validation,
      yes, we know, Olivia,
      Show us your code, [and possible errorlines]

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: OnSubmit using two script validations

        Tom de Neef wrote:
        "Olivia Towery" <timwebs@adelph ia.netwrote
        >I cannot figure out how to complete two script validations onsubmit. Only
        >the first one listed runs. If anyone knows how to do this, please help.
        >
        onsubmit=valida te1(),validate2 ()
        or
        onsubmit=valida te1()&&validate 2()
        This is _not_ the proper way as validation will be performed but form
        submission will take place even if validation fails.

        Furthermore, in both cases the attribute value would have to be quoted, due
        to the characters `(', `)', `,', and `&' in it:



        Should be:

        <form action="..." ...
        onsubmit="retur n validate1(this) && validate2(this) ">

        If either validation fails, it should return `false' so that the boolean
        expression evaluates to `false', which is returned to the event handler and
        causes the form not to be submitted.

        Another way that is a little bit easier to maintain:

        function validate(f)
        {
        return validate1(f) && validate2(f);
        }

        <form action="..." ... onsubmit="retur n validate(this)" >

        Passing the `this' value saves one from having to look up the form object
        reference in either validation method again.


        PointedEars
        --
        realism: HTML 4.01 Strict
        evangelism: XHTML 1.0 Strict
        madness: XHTML 1.1 as application/xhtml+xml
        -- Bjoern Hoehrmann

        Comment

        Working...