Solved

Checkbox Validation

Posted on 2008-10-22
2
861 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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