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

Validations of Fields in a Loop

Status
Not open for further replies.

Coding

Programmer
Aug 13, 2000
25
0
0
CA
Can anyone tell me if there is any chance to validate fields that are in a for-next loop. I tried to validate them by this line of code:

function validateUser() {

if (document.rfqForm.description.value=="")
...
document.rfqForm.submit(form);
}
...
<input type=&quot;button&quot; name=&quot;addItems&quot; value=&quot;Add Items&quot; OnClick=&quot;validateUser(this.form)&quot;>
...
but it doesn't work for the loop. It seems that JavaScript can not reach values inside the for-next function since the values in the loop are local. Am I right?
If there is no way to find the solution for this, can anybody help me to show me then how to validate the fields via ASP code. What function is the best for validation and is it possible to get similar alert window in ASP like in JavaScript.
Thanks.
 
Of course it's possible:

function validateUser() {
f = document.formName; // jsut to make things shorter
for (n=0; n<f.elements.length; n++)
if (f.elements[n].type == &quot;text&quot; && f.elements[n].value=&quot;&quot;)
// do something
//. . .
f.submit();
}

I always use this method. If you check my posts you'll find many examples of this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top