Solved

Checkbox Validation

Posted on 2008-10-22
2
849 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
  • 2
2 Comments
 
LVL 28

Expert Comment

by:omgang
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now