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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.