?
Solved

Checkbox Validation

Posted on 2008-10-22
2
Medium Priority
?
868 Views
Last Modified: 2012-06-27
Hello:

What I am trying to do is submit the form. However if the ValueTextBox is less then or equal to 5 the form should not be submitted until the checkbox is checked.

<head>
<script type = text/vbscript>
Function theForm_onSubmit
If Document.theForm.ValueTextBox.Value <= "5"  Then
MsgBox "Please select a response!"
theForm_OnSubmit = False
Else
If Document.theForm.ValueTextBox.Value <= "5" AND Document.theForm.Ques.checked  Then
theForm_OnSubmit = True
End If
End Function
</script>
</head>
<body>
<form method="POST" name="theForm" action="abc.asp">
<input type="checkbox" name="Ques" value="Hi"><input type="text" name="ValueTextBox" size="20" value="<%=Request("NumValue")%>">
<input type="submit" value="Submit" name="B1">
</form>
</body>
0
Comment
Question by:RecipeDan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 22781983
The first conditional will always be True when ValueTextBox <= 5 regardless of wheter the check box is checked or not.  Try reversing the conditionals.

Function theForm_onSubmit
If Document.theForm.ValueTextBox.Value <= "5" AND Document.theForm.Ques.checked  Then
theForm_OnSubmit = True
Else
If Document.theForm.ValueTextBox.Value <= "5"  Then
MsgBox "Please select a response!"
theForm_OnSubmit = False
End If
End Function

OM Gang
0
 
LVL 28

Accepted Solution

by:
omgang earned 2000 total points
ID: 22782009
Actually

Function theForm_onSubmit
If Document.theForm.ValueTextBox.Value <= "5" AND Document.theForm.Ques.checked = False  Then
MsgBox "Please select a response!"
theForm_OnSubmit = False
Else
theForm_OnSubmit = True
End If
End Function

OM Gang
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question