Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Comparing field values


Message #1 by "rick frank" <rickf@d...> on Sun, 22 Jul 2001 17:48:22
Hi there,

There is a little bug in the previous code.

Change the line where field2 is compared with field 1 to this:

if ((document.frmValidate.txtTwo.value * 1) <= 
(document.frmValidate.txtOne.value * 1))

This makes sure that the field values are casted to numbers, so they will 
be compared as numbers and not as strings. This is necessary to prevent 
situations where "23" is larger than "222" for example.

Regards,

Imar


> Hi,
> 
> I have a quick, probably very simple question.
> (My manual is very long on theory & short on examples)
> I need to compare two fields (ranges -the 2nd must be higher than the 
> first or empty)
> I also need to do this as a single line of code triggered by change in 
the 
> 2nd field.
> Is there a simple way to do this?
> 
> Thanks

  Return to Index