Numbers in forms, 0.5 vs .5

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rjames.clarke@gmail.com

    Numbers in forms, 0.5 vs .5

    Hi all,

    I am (have) wrote an intranet industrial app that requires the user to
    enter a number which is compared to a high and low limit. If the low
    or high limits have a 0 in front of the decmial the entered value must
    also.

    The actual comparison is done in javascript as pasted below. If a
    return true is given then the data is written to the database.

    ex

    low limit 0.5
    high limit 0.6
    entered value .55 is returned as OUT OF TOLERANCE CONDITION

    whereas entered value of 0.55 is returned as GOOD!

    For the time being I have consoled my users to be sure to enter a
    leading 0 when dealing with decimals.

    How do I correct this, such that .5 and 0.5 are considered valid
    entries?

    if ((document.test form.actual_val ue.value <
    document.testfo rm.upper_limit. value) &&
    (document.testf orm.actual_valu e.value >
    document.testfo rm.lower_limit. value))
    {
    alert("Data Good\n\nWriting the Data\n to the Database")
    document.testfo rm.pass_fail.va lue="P"
    return true
    }
    else
    {
    input_box=confi rm("Click OK to record a NC or Cancel to Re-enter");
    if (input_box==tru e)
    {
    // Output when OK is clicked
    alert ("You clicked NC, TAG the item as REJECT (RED)");
    return true
    }
    else
    {
    // Output when Cancel is clicked
    alert ("You clicked cancel");
    return false
    }
    }

  • Ewoud Dronkert

    #2
    Re: Numbers in forms, 0.5 vs .5

    rjames.clarke@g mail.com wrote:[color=blue]
    > The actual comparison is done in javascript as pasted below.[/color]

    Off topic.

    --
    E. Dronkert

    Comment

    • Oli Filth

      #3
      Re: Numbers in forms, 0.5 vs .5

      rjames.clarke@g mail.com said the following on 16/09/2005 13:25:[color=blue]
      > Hi all,
      >
      > I am (have) wrote an intranet industrial app that requires the user to
      > enter a number which is compared to a high and low limit. If the low
      > or high limits have a 0 in front of the decmial the entered value must
      > also.
      >
      > The actual comparison is done in javascript as pasted below. If a
      > return true is given then the data is written to the database.
      >[/color]

      Never rely on client-side validation alone, especially if you're then
      putting the data into a database! Always validate server-side!

      --
      Oli

      Comment

      • rjames.clarke@gmail.com

        #4
        Re: Numbers in forms, 0.5 vs .5

        So it would seem, ok you can go over to comp.lang.javas cript and answer
        the question.

        Comment

        • rjames.clarke@gmail.com

          #5
          Re: Numbers in forms, 0.5 vs .5

          Why?
          If it matters this is an internal company only application.

          Comment

          • Malcolm Dew-Jones

            #6
            Re: Numbers in forms, 0.5 vs .5

            rjames.clarke@g mail.com originally asked something about javascript, then
            apparently answered himself in the third person...


            rjames.clarke@g mail.com wrote:
            : So it would seem, ok you can go over to comp.lang.javas cript and answer
            : the question.


            but then confused us all further with the odd questioning response to his
            own answer...


            rjames.clarke@g mail.com wrote:
            : Why?
            : If it matters this is an internal company only application.


            The answer to '"Why" you should go to comp.lang.javas cript' is because the
            javascript gurus hang out there.

            The claimed fact that this is an internal application makes no difference
            to which group would best help a person.

            I can't imagine why he would need to post a message to tell himself to
            visit that other group, and certainly don't understand why he would then
            question his own (good) advice to himself!

            Bye.

            --

            This programmer available for rent.

            Comment

            • Default User

              #7
              Re: Numbers in forms, 0.5 vs .5

              rjames.clarke@g mail.com wrote:
              [color=blue]
              > So it would seem, ok you can go over to comp.lang.javas cript and
              > answer the question.[/color]

              So what would seem?



              Brian

              Comment

              • Default User

                #8
                Re: Numbers in forms, 0.5 vs .5

                rjames.clarke@g mail.com wrote:
                [color=blue]
                > Why?[/color]

                Why What?
                [color=blue]
                > If it matters this is an internal company only application.[/color]

                If what matters?



                Brian

                Comment

                • Oli Filth

                  #9
                  Re: Numbers in forms, 0.5 vs .5

                  rjames.clarke@g mail.com said the following on 16/09/2005 22:47:[color=blue]
                  > Why?[/color]

                  Why? Because it's good programming practice. Always validate as close to
                  the database insertion as you can.


                  --
                  Oli

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: Numbers in forms, 0.5 vs .5

                    rjames.clarke@g mail.com wrote:[color=blue]
                    > Why?
                    > If it matters this is an internal company only application.
                    >[/color]

                    So it's only an internal application. Over 85% of successful hacking
                    attempts, etc. are from internal sources.

                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    Working...