Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dynamic ASP form - prevent user choosing default

Thread Tools

Dynamic ASP form - prevent user choosing default
Posts: n/a

I have an ASP form which only includes an option list. The list is
dynamically created but includes a default value, which is an
instruction "Select a group".

The code is shown at bottom.

I want to ensure the user does not submit the form with the default
value selected.

I think something like the javscript handler available at: might be what I need.

(script extract)

function checkvalue() {
if (triviaform.TriviaAnswer.optio*ns[0].selected) {
alert('You must enter your response.');

However this script works for a static form with pre numbered options
ie option 0 is the default option.

How do I modify this script (or get another one) which will prevent my
default value being selected?

Thanks ColinK


<form action="LeaderSelect2.asp" method="get">
<select name="GroupName">
<option>Select a Group</option>
' Continue until we get to the end of the recordset.
Do While Not rsGroupP.EOF
' For each record we create a option tag and set it's value to
the GroupID
<option value="<%= rsGroupP.Fields("GroupName") %>"><%=

rsGroupP.Fields("GroupName") %></option>
' Get next record

End If
<input type="submit" name="Submit" value="Add a Leader to this

Reply With Quote
Curt_C [MVP]
Posts: n/a
      08-08-2005 Removed) wrote:
> Hi
> I have an ASP form which only includes an option list. The list is
> dynamically created but includes a default value, which is an
> instruction "Select a group".

Give the "select a group" item a specific value (or no value) and check
for that when they click the button.

Curt Christianson
Reply With Quote
Posts: n/a
And validation can be done clientside with JavaScript:

Javascript Field Validations -- Client Side Scripting by Nannette
Thacker - 8/19/1999

Form Validation Using Javascript - 9/19/1998
Good tips such as saving JavaScript functions in a file called
DataValidation.js and including this in pages that need this.
JavaScript functions.

WebDaily: Your daily source for Web Technology Tips and Tricks! -
Just checks if fields filled in.

Or server-side with ASP (my favorite):

Server-Side Form Validation by Dianna Leech - 12/1/1999

An Email Validation Routine by Joćo Vieira - 4/11/1999
Somewhat shorter.

An Email Validation Script by Ben Durbin - 5/19/1999

Form Handler: Some light form validation and error notification.
Uses function to loop thru all fields in a form.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...

*** Sent via Developersdex ***
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent form submission only from default action Stanimir Stamenkov Javascript 13 03-20-2008 07:15 PM
prevent form submission with dynamic onsubmit? nybble Javascript 1 10-02-2005 05:26 PM
Dynamic ASP form - prevent user choosing default. Javascript 0 08-07-2005 01:46 PM
Revised: A form -to- dynamic form -to- dynamic checkboxes pizzy Javascript 7 03-23-2005 10:53 PM
Dynamic Form with a Dynamic Form inside it... pizzy Javascript 4 03-18-2005 05:10 AM