Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 12th, 2005, 02:16 PM
Registered User
 
Join Date: Jan 2005
Location: Long Beach, CA, .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieving Field Names

I want to perform some validation before a user submits a form. Is there any way for me to check each field to see if it's been filled in by the user. Right now, I have to manually add these to my script. I thought maybe I could use javascript to scroll through all fields to see if they'd been filled in or not. Here is my current code below. In my example you see that I have two if statements, one for each field on my form. What if I had 10 or 20 fields on my form. Assuming they are all required fields, rather than keying in 10 or 20 if statements, can I scroll through the fields instead? Thanks

function validateForm(theForm) {
    if (!validRequired(theForm.begindate,"Begin Date"))
        return false;
    if (!validRequired(theForm.enddate,"End Date"))
        return false;
    return true;
}

function validRequired(formField,fieldLabel) {
    var result = true;

    if (formField.value == "")
    {
        alert('Please enter a value for the "' + fieldLabel +'" field.');
        formField.focus();
        result = false;
    }
    return result;
}


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT For Each - Field Names lahatfield XSLT 6 May 15th, 2007 06:33 AM
Error getting field names from query vbark Access VBA 1 January 23rd, 2007 09:04 PM
Replacing field names in datasheet philiprodley Access VBA 1 August 10th, 2006 12:47 PM
Get Field Names fizzerchris Classic ASP Databases 1 February 25th, 2006 05:06 AM
Retrieving Dynamic Field Names tdaustin Classic ASP Basics 4 January 12th, 2004 11:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.