Forums

ASP

This topic is locked

Form validation

Posted 01 Jun 2008 02:07:26
1
has voted
01 Jun 2008 02:07:26 Gee Rode posted:
Hi
Can anyone help with this. I have a form with dropdowm menu. I need to ensure that the user makes a selection from the dropdown menu before the form is sent. The problem I have is with the default selection. That SELECTION is not part of the dropdown list they shouild select from. I have tried this but cant get it to work. The form is sent regardless of what option is selected. Here is the code.

I do not want to use javascript as some people have this turned off.

Thanks for any help.
---------------------------------------------------------------------------------------
------------------------------ASP CODE--------------------------------------------

<%
If Request.Form("selTest" = "" Then
errMsg = "Please Select a value from the list"
Else
'A value was selected, your good to go
End If
%>

-------------------------------FORM---------------------------------------------
<form action="" method="post" enctype="multipart/form-data" name="Test" >
<select name=selTest>
<option value="">Please Select From list</option>
<option value="1">ONE</option>
<option value="2">TWO</option>
<option value="3">THREE</option>
</select></p>
<input type="text" name="text1">
<p>
<input type="submit" >
</p>
</form>

Replies

Replied 01 Jun 2008 11:50:01
01 Jun 2008 11:50:01 Alan C replied:
Hi

Can't help with the asp, I only do php <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

but it sounds to me like you want a bit of javascript, I've seen scripts that deactivate the submit button until a selection has been made, something like that would work
Replied 02 Jun 2008 01:48:46
02 Jun 2008 01:48:46 Gee Rode replied:
Thanks for the input. However, the problem with javascript is, the user may have javascript turned off. Like my client, he had javascript turned off and thought the form did not work.

Do you have a php solution that can work on windows server?

ThANKS
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi

Can't help with the asp, I only do php <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

but it sounds to me like you want a bit of javascript, I've seen scripts that deactivate the submit button until a selection has been made, something like that would work
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 02 Jun 2008 14:04:53
02 Jun 2008 14:04:53 Alan C replied:
Hi

can't think of a way around this - maybe I'm not thinking laterally, but as I see it, you will not know that there is not selection until the form input arrives at the server, so this checking has to be done clientside

I did something with a form where it was all serverside validation, in that case the fields etc were all checked and any that were unacceptable were flagged, then the whole of the form was sent back to the client - the flagged items were then presented as a different css class that changed the backbround colour of the field, I think it also incorporated a message that was added to the field name - all in all a bit messy

sorry I don't have a better suggestiong <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Reply to this topic