Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Dynamic ASP form - prevent user choosing default

 
 
iam247@gmail.com
Guest
Posts: n/a
 
      08-07-2005
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".

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:
http://www.devx.com/tips/Tip/13767 might be what I need.

(script extract)

<SCRIPT>
function checkvalue() {
if (triviaform.TriviaAnswer.optio*ns[0].selected) {
alert('You must enter your response.');
event.returnValue=false;
}
}
</SCRIPT>

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

MY FORM

<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
rsGroupP.MoveNext
Loop

End If
%>
<input type="submit" name="Submit" value="Add a Leader to this
Group">
</form>

 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      08-08-2005
http://www.velocityreviews.com/forums/(E-Mail 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
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
 
Reply With Quote
 
 
 
 
Bullschmidt
Guest
Posts: n/a
 
      08-12-2005
And validation can be done clientside with JavaScript:

Javascript Field Validations -- Client Side Scripting by Nannette
Thacker - 8/19/1999
http://www.shiningstar.net/articles/...vascriptvalida
tions.asp?ID=AW

Form Validation Using Javascript - 9/19/1998
http://www.4guysfromrolla.com/webtech/091998-1.shtml
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! -
10/27/1998
http://www.4guysfromrolla.com/webtech/102798-1.shtml
Just checks if fields filled in.

Or server-side with ASP (my favorite):

Server-Side Form Validation by Dianna Leech - 12/1/1999
http://www.4guysfromrolla.com/webtech/120199-1.shtml

An Email Validation Routine by Joćo Vieira - 4/11/1999
http://www.4guysfromrolla.com/webtech/041199-1.shtml
Somewhat shorter.

An Email Validation Script by Ben Durbin - 5/19/1999
http://www.4guysfromrolla.com/webtech/051999-1.shtml
Longer.

Form Handler: Some light form validation and error notification.
http://www.asp101.com/samples/form_handler.asp
Uses function to loop thru all fields in a form.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

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. iam247@gmail.com 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



Advertisments