Using VB script with ASP and HTML forms.

V

vindictive27

Hello,

I'm trying to use a VB script inside of an ASP/HTML form I've created
for an internal business website. I'm just using some standard if ...
then statements to verify if all required fields have information, and
if so, to go ahead and submit the form. If the fields do not have the
required information, I am displaying a message box notifying the user
that the field must be filled in to allow submission. This works for
all fields, except the last few on the form. Here is the code I have:

If (document.MyForm.Radio9.checked) then
if (document.MyForm.Answer16a.value)="" then
if (document.MyForm.Answer16b.value)="" then
MsgBox("The More Information field
is required")
validation=false
end if
end if
else if not(document.MyForm.Radio10.checked) then
MsgBox("The More Information field is
required")
validation=false
else if (document.MyForm.Radio10.checked) then
validation=true
End If

Now, what happens is, it totally ignores that code -- and it submits
the form anyway, totally ignoring all of the other code for verifying
fields that worked previous to adding that bit.

Any ideas? Any other boards I should post in?

Thank you.
 
H

Hal Rosser

Hello,

I'm trying to use a VB script inside of an ASP/HTML form I've created
for an internal business website. I'm just using some standard if ...
then statements to verify if all required fields have information, and
if so, to go ahead and submit the form. If the fields do not have the
required information, I am displaying a message box notifying the user
that the field must be filled in to allow submission. This works for
all fields, except the last few on the form. Here is the code I have:

If (document.MyForm.Radio9.checked) then
if (document.MyForm.Answer16a.value)="" then
if (document.MyForm.Answer16b.value)="" then
MsgBox("The More Information field
is required")
validation=false
end if
end if
else if not(document.MyForm.Radio10.checked) then
MsgBox("The More Information field is
required")
validation=false
else if (document.MyForm.Radio10.checked) then
validation=true
End If

Now, what happens is, it totally ignores that code -- and it submits
the form anyway, totally ignoring all of the other code for verifying
fields that worked previous to adding that bit.

Any ideas? Any other boards I should post in?

This client-side code should be done in javascript inside <script
type="text/javascript"> </script> tags.
Don't mix up your Client-side code with your ASP (server-side) code. Well,
your ASP code can WRITE the javascript code, but keep in mind the javascript
is executed in the browser - after the server has sent it to the browser,
Javascript, by the way, is case-sensitive - for instance the word 'if'
should be lower-case.
HTH
HR
 
R

rowe_newsgroups

Hello,

I'm trying to use a VB script inside of an ASP/HTML form I've created
for an internal business website. I'm just using some standard if ...
then statements to verify if all required fields have information, and
if so, to go ahead and submit the form. If the fields do not have the
required information, I am displaying a message box notifying the user
that the field must be filled in to allow submission. This works for
all fields, except the last few on the form. Here is the code I have:

If (document.MyForm.Radio9.checked) then
if (document.MyForm.Answer16a.value)="" then
if (document.MyForm.Answer16b.value)="" then
MsgBox("The More Information field
is required")
validation=false
end if
end if
else if not(document.MyForm.Radio10.checked) then
MsgBox("The More Information field is
required")
validation=false
else if (document.MyForm.Radio10.checked) then
validation=true
End If

Now, what happens is, it totally ignores that code -- and it submits
the form anyway, totally ignoring all of the other code for verifying
fields that worked previous to adding that bit.

Any ideas? Any other boards I should post in?

Thank you.

First off, you are in the entirely wrong newsgroup. You want one that
deals with vb script and ASP, and not one that specializes in Visual
Basic .NET and somewhat in ASP.NET. I don't know the proper newsgroup
to refer you to, but you definitely don't want to post to one that
includes "dotnet" in it's name.

My personal recommendation (since you're in the .NET neck of the
woods) is to scrap the classic ASP website and migrate it to ASP.NET.
If you upgrade you can then simply use the various validator controls
that ship with the framework (RequiredField, RegularExpress, Range, et
al). These encapsulate not only the client side javascript, but also
the server side validation routines. After all, client side code does
not make an application secure - any "hacker" could strip off the
client side validation and send in erroneous, and/or dangerous, form
values.

Thanks,

Seth Rowe
 
C

Cor Ligthert[MVP]

Vindictive,

In my opinion are you using VB.Net code, don't mix that up with VB.Script.

VB.Net code is build (compiled) to a DLL. That is what happens in ASPNET as
well.

ASP is as well different from ASP.Net. In ASP can be at the client side be
used Javascript and VBscript. On the serverside it is forever VBScript. The
latter is AFAIK impossible in ASP.Net.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top