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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data validation

Status
Not open for further replies.

mbwmbk

Programmer
Dec 12, 2002
19
US
I have a form which generate the input box dynamically according to the data in the database. When
submitting the form (js function), how can I check if the input box is filled?

if not rs1.EOF then
Response.Write &quot;<TABLE align=center frame=&quot;&quot;below&quot;&quot; cellPadding=1 cellSpacing width=600>&quot;
count=0

while not rs1.EOF
count=count+1
Response.Write &quot;<TR border = 0>&quot;& vbCrLf
'min
if rs1.Fields(20)&&quot;&quot;<>&quot;&quot; then
Response.Write &quot;<td><input id=lbmin&quot;&count&&quot; name=lbmin&quot;&count&&quot; value=&quot;&quot;&quot;&rs1.fields(20)&&quot;&quot;&quot; ></td>&quot;
else
Response.Write &quot;<td width=80>&nbsp;</td>&quot; & vbCrLf
end if

'ave
if rs1.Fields(21)&&quot;&quot;<>&quot;&quot; then
Response.Write &quot;<td><input id=lbave&quot;&count&&quot; name=lbave&quot;&count&&quot; value=&quot;&quot;&quot;&rs1.fields(21)&&quot;&quot;&quot; ></td>&quot;
else
Response.Write &quot;<td width=80>&nbsp;</td>&quot; & vbCrLf
end if

'max
if rs1.Fields(19)&&quot;&quot;<>&quot;&quot; then
Response.Write &quot;<td><input id=lbmax&quot;&count&&quot; name=lbmax&quot;&count&&quot; value=&quot;&quot;&quot;&rs1.fields(19)&&quot;&quot;&quot; ></td>&quot;
else
Response.Write &quot;<td width=80>&nbsp;</td>&quot; & vbCrLf
end if


Response.Write &quot;</TR>&quot;& vbCrLf

rs1.MoveNext
wend
Response.Write &quot;</table>&quot;& vbCrLf

Response.Write &quot;<input type=hidden name=count value=&quot;&count&&quot;>&quot;& vbCrLf
rs1.Close()
%>

 
>> how can I check if the input box is filled?

if( 0 < document.myform.myeditbox.value.length){

alert(&quot;edit box has some value in it&quot;);
} -There are only 10 types of people in the world, those who understand binary and those who don't-

-pete
 
All the input boxes are dynamically generated. For example, in one form, item1 has min, ave and max value, item2 has only min and ave value; and item3 has only min value. (and there may have n-number on item in one form, and various combination of values(min, ave, max) for each item.). How can I reference those input boxes in the jscript before submitting the form?
 
The best way is to use the form element array...

message = &quot;&quot;
for (x=0; x < document.myForm.elements.length; x++){
if (document.myForm.elements[x].value.length == 0){
message += &quot;\n - &quot; + document.myForm.elements[x].name
}
}

if (message != &quot;&quot;){
alert (&quot;Please fill the following:&quot; + message)
}
else{
document.myForm.submit()
} Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
mikewolf@tst-us.com (Do not email regarding this thread unless requested - I don't check this account regularly)
 
For example your lbmincounter input text:

try{
var i = 0;
while(1>0){/allways
// you could allso fill an array with the value and do the checking later.
if(document.getElementById('lbmin' + i.toString()).value==&quot;&quot;){
//do something
}
i++;
}
}catch(e){}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top