-
October 28th, 2003, 07:35 AM
#1
validating checkboxes
Dear All,
I have an input form where the user must enter his name, surname, e-mail address and choose from three topics, namely Conference, Leisure or Corporate. He can choose as many as he like, however, he has to choose one before submitting the form.
How can I do the validation on these checkboxes?
I came up with this code:-
If request.form("Conference") = "" then
er = 1
End IF
if er <> 1 then
If request.form("Leisure") = "" then
er = 1
End IF
end if
if er <> 1 then
If request.form("Corporate") = "" then
er = 1
End IF
end if
If er = 1 then
message = "You have to choose at least one check box"
end if
However, how can I stop the form from being submitted?
Thanks for your help and time
www.johannmontfort.com
-
October 28th, 2003, 02:02 PM
#2
If request.form("Conference") = "" then
er = 1
End IF
if er <> 1 then
If request.form("Leisure") = "" then
er = 1
End IF
end if
if er <> 1 then
If request.form("Corporate") = "" then
er = 1
End IF
end if
If er = 1 then
message = "You have to choose at least one check box"
end if
What code is that? Clientside or server side? You seem to be confused between client side and server side scripting.
Before submitting the form, i.e. in the client side you dont have access to the request object. It is a server side object.
You should be able to access form controls as
document.<formname>.<controlname>.value
where <formname> and <controlname> have to be replaced with the name of the form and the control respectively.
For a javascript example of what you are trying go to
http://www.w3schools.com/js/tryit.as...s_formvalidate
Satish
-
October 29th, 2003, 04:51 AM
#3
Ok thanks mate, I will search for that.
www.johannmontfort.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|