Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1751
Number of posts: 4473

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Select Case embedded in For Each Loop Posted by jroberts on 27 Feb 2002 at 11:10 AM
I need some advice here. I'm trying to do form validation using Select Case statements embedded within a For Each Loop. Something isn't working correctly. I want it to display all error messages at once, but it is only displaying one at a time. Any clue what's wrong, or any other ideas in accomplishing this? Here is an example of what I've done so far:

For Each Field in Request.Form
Select Case Field
Case "fieldname"
If [Validation Statment] Then
[Display Error Message]
End If
etc...
etc...
End Select
Next

Report
Re: Select Case embedded in For Each Loop Posted by dipys on 5 Mar 2002 at 2:21 AM
: I need some advice here. I'm trying to do form validation using Select Case statements embedded within a For Each Loop. Something isn't working correctly. I want it to display all error messages at once, but it is only displaying one at a time. Any clue what's wrong, or any other ideas in accomplishing this? Here is an example of what I've done so far:
:
: For Each Field in Request.Form
: Select Case Field
: Case "fieldname"
: If [Validation Statment] Then
: [Display Error Message]
: End If
: etc...
: etc...
: End Select
: Next
:
: Hi, the best method is to validate in the client side itself rather than the server side, unless you are drawing records from the database. That way you save trips to the server. You could write a function that gets called on Submit of the form and validate the fields using the form collection.
A simple example goes here:
<script language = javascript>
function fnCheck()
{
if ((frmTest.txt1.value == "") || (frmTest.txt2.value == ""))
{
alert("Wrong");
return false;
}
else
{
return true;
}
</script>
<form id = frmTest name = frmTest method = post action = "Test.asp">
<input id = txt1 name = txt1>
<input id = txt2 name = txt2>
<input type = Submit value = "OK" onclick = "return fnCheck()"
</form>



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.