# Numbers in forms, 0.5 vs .5

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
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.testform.actual_value.value <
document.testform.upper_limit.value) &&
(document.testform.actual_value.value >
document.testform.lower_limit.value))
{
alert("Data Good\n\nWriting the Data\n to the Database")
document.testform.pass_fail.value="P"
return true
}
else
{
input_box=confirm("Click OK to record a NC or Cancel to Re-enter");
if (input_box==true)
{
// Output when OK is clicked
alert ("You clicked NC, TAG the item as REJECT (RED)");
return true
}
else
{
// Output when Cancel is clicked
return false
}
}

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

rjames.clarke@gmail.com wrote:

Off topic.

--
E. Dronkert

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

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

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

rjames.clarke@gmail.com wrote:

So what would seem?

Brian

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

rjames.clarke@gmail.com said the following on 16/09/2005 13:25:

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

--
Oli

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

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

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

apparently answered himself in the third person...

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

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

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

The answer to '"Why" you should go to comp.lang.javascript' 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.

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

rjames.clarke@gmail.com wrote:

Why What?

If what matters?

Brian

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

rjames.clarke@gmail.com said the following on 16/09/2005 22:47:

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

--
Oli

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

rjames.clarke@gmail.com wrote:

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@attglobal.net
==================