Select Case embedded in For Each Loop - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Select Case embedded in For Each Loop

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

Comments

  • dipysdipys Posts: 8Member
    : 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:

    function fnCheck()
    {
    if ((frmTest.txt1.value == "") || (frmTest.txt2.value == ""))
    {
    alert("Wrong");
    return false;
    }
    else
    {
    return true;
    }





Sign In or Register to comment.