Solved

Checkbox Validation

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HOW CAN I TRANSFER AN COLUMN DATA TO ROW FOR ANALYSIS 7 42
2012 SQL to JSON Select 5 32
Session on Html 8 42
SP converting date time to date and time separately 2 21
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

696 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