Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > vbScript Validate Checkbox

Reply
Thread Tools

vbScript Validate Checkbox

 
 
Scott
Guest
Posts: n/a
 
      09-24-2006
I'm trying to validate a checkbox below on Sumbit. If the checkbox named
"myForm.myCheckBox" isn't checked, then the code in CODE 1 displays
False, which is correct.

However, when I test that same value in an IF statement in CODE 2, the IF
part doesn't catch the false. I'm also having trouble if the user clicks
yes. On the line with "myForm.myCheckBox.value= True", which should check
the box for the user, it doesn't select the checkbox control.


CODE 1 ***************
Alert "Checkbox Value= " & myForm.myCheckBox.value, vbExclamation,
"Test"


CODE 2 **************

<SCRIPT TYPE="text/vbscript" LANGUAGE="VBScript">

Function myForm_OnSubmit()

If myForm.myCheckBox.value= "False" Then

Alert "Checkbox Value= " & myForm.myCheckBox.value, vbExclamation,
"Test"

result=MsgBox ("To complete the test, you " & vbCrlf & _
"must check the box! " & vbCrlf & vbCrlf & _
"Do you want to correct this?",vbYesNo+vbQuestion,"myQuestion")
Select Case result
Case 6
myForm_OnSubmit = False
myForm.myCheckBox.value= True
Case 7 ' user cancelled

End Select
End If

End Function
</SCRIPT>




 
Reply With Quote
 
 
 
 
Elyo Ravuna
Guest
Posts: n/a
 
      09-25-2006
Dear Scott, You have to use myCheckBox.checked instead of myCheckBox.value.

myCheckBox.checked is boolean, so you also need to remove the double quotes
from the "false" keyword.

I hope it helps, please let me know if you encounter any difficulties.

Best regards.
Elyo Ravuna


"Scott" wrote:

> I'm trying to validate a checkbox below on Sumbit. If the checkbox named
> "myForm.myCheckBox" isn't checked, then the code in CODE 1 displays
> False, which is correct.
>
> However, when I test that same value in an IF statement in CODE 2, the IF
> part doesn't catch the false. I'm also having trouble if the user clicks
> yes. On the line with "myForm.myCheckBox.value= True", which should check
> the box for the user, it doesn't select the checkbox control.
>
>
> CODE 1 ***************
> Alert "Checkbox Value= " & myForm.myCheckBox.value, vbExclamation,
> "Test"
>
>
> CODE 2 **************
>
> <SCRIPT TYPE="text/vbscript" LANGUAGE="VBScript">
>
> Function myForm_OnSubmit()
>
> If myForm.myCheckBox.value= "False" Then
>
> Alert "Checkbox Value= " & myForm.myCheckBox.value, vbExclamation,
> "Test"
>
> result=MsgBox ("To complete the test, you " & vbCrlf & _
> "must check the box! " & vbCrlf & vbCrlf & _
> "Do you want to correct this?",vbYesNo+vbQuestion,"myQuestion")
> Select Case result
> Case 6
> myForm_OnSubmit = False
> myForm.myCheckBox.value= True
> Case 7 ' user cancelled
>
> End Select
> End If
>
> End Function
> </SCRIPT>
>
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
validate multiple checkbox premadarsh Software 0 02-05-2010 11:09 AM
Validate CheckBox Rowena ASP .Net 7 12-02-2009 08:26 PM
processing mutiple checkbox selections in vbscript .Net Sports ASP General 4 09-29-2009 05:50 PM
Validate checkbox from dropdownlist value Luigi ASP .Net 3 05-07-2009 10:39 AM
validate fields when a dynamic checkbox is selected bobby1041 ASP General 1 10-05-2005 06:28 AM



Advertisments