Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check number fields are allowd values

Status
Not open for further replies.

philrm

MIS
Joined
Jun 1, 1999
Messages
58
Location
AU
I have 2 fields on a form Depth 1 and Depth 2. They submit data to an SQL 7 data base. I need to ensure that the value entered in Depth 2 is higher than that in Depth 1. How do I do this. Dates do not seem to be a problem but the data is a floating numeric data type in the data base.This would be good enough for what I want
However the users would also like to have the value in Depth 2 also validated for the next record. I.E. If more than one depth range is entered, then the value in Depth 1 of the second record must be >= Depth 2 in the previous record????? Is this even possible??????
 
hie
>>I need to ensure that the value entered in Depth 2 is higher than that in Depth 1. How do I do this
script:----------
function validateit(){
var formobj=document.forms.f1
var obj1=formobj.Depth_1
var obj2=formobj.Depth_2
if (obj2.value>obj1.value)
return true
else return false
}
--------------
form:---------------

<form name=f1.. onsubmit=&quot;validateit()&quot;> regards, vic
 
Philrm

What do you mean by this
&quot;However the users would also like to have the value in Depth 2 also validated for the next record. I.E. If more than one depth range is entered, then the value in Depth 1 of the second record must be >= Depth 2 in the previous record????? Is this even possible??????&quot;

My understanding is you want to have this condition

Record N: Depth 2 > Record N: Depth 1 > Record N-1: Depth 2 > Record N-1: Depth 1

If my understanding is correct, read on.
I'm not sure if Record N and Record N-1 are all on the same form and submitted altogether or submitted one after the other.

For the former, all you need is a conditional statement
if (document.RecordNdepth2.value>document.RecordNdepth1.value && document.RecordN_1depth2.value>document.RecordN_1depth1.value) {return true;} else {return false;}

For the later, you can pass the value back to the hidden fields of the form after you update the database and do the comparison again.

Regards
 
philrm,

if im understanding you correctly, and i may be way off here:

you have one form submitting fields Depth1 and Depth2 to a database where Depth1 must be less than Depth2. For that you can use vituz's post.

Then in another form you want the Depth2 value pulled from the database and checked against a Depth 3 in another form?

if this is the case, you will need to use an SQL Querry to pull that value from the database and simply use the same code (with any necessary variable name changes) to check it again.
Hope it helps ;)

~ jsLove
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top