• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 11271
  • Last Modified:

VBScript Form Validation

Hi all,

I have a form in a webpage which i need to validate, I am already using VBScript in another portion of that page which the button in the form calls that VBScript so i can't use Javascript.

The page is here:
http://66.223.16.116/help.htm

The current version has a drop down that when a specific option is slected shows or hides a text box.

basically i want to do the same for the upload button enabling / disabling it, if a drop down option is selected or enable/disable it when the text box is filled/emptied.

I know it's not going to work if i use javascript, because the items are not within a <FORM> tag. so if I can just force people to either select a form item or insert text into the text box, by means of an alert.

Browser / platform independace doesn't matter because i have an active X component running in there already

Here's the code:

<...>
<SCRIPT LANGUAGE="VBScript">
Sub Select_OnClick
     UploadCtl.Select
End Sub

Sub SelectFolder_OnClick
     UploadCtl.SelectFolder
End Sub

Sub Remove_OnClick
     UploadCtl.RemoveHighlighted
End Sub

Sub RemoveAll_OnClick
     UploadCtl.RemoveAll
End Sub

Sub Upload_OnClick
     UploadCtl.RemoveAllFormItems
     UploadCtl.AddFormItem "albumselect", albumselect.Value
     UploadCtl.AddFormItem "albumcreate", albumcreate.Value
     UploadCtl.Upload
End Sub

Sub UploadCtl_UploadProgress(FilePercent, OverallPercent)
     if OverallPercent > 0 Then     ProgressTable.Width = 360 * OverallPercent / 100
End Sub

Sub UploadCtl_WaitingForReply
     ProgressText.innerText = "Creating Thumbails..."
End Sub

Sub OnStop
     UploadCtl.Stop
     ProgressTable.Width = 1
End Sub

</SCRIPT>
<..>

                      <td>
                       
<select name="album" onChange="javascript:document.getElementById('new_album').style.display=selectedIndex<1?'inline':'none';">
                          <OPTION>Or create a new one --></OPTION><OPTION value="5">Kingsville - September 2004</OPTION><OPTION value="4">test</OPTION>
                        </select></td>
                      <td> <div id="new_album" style="display:visible">
                          New:<input type="TEXT" name="albumcreate" onkeyup="this.form.UPLOAD.disabled=this.value.replace(/\s+/,'')=='';">
                        </div></td>
<..>

                      <td align=center colspan=2><FORM><input name="UPLOAD" type="BUTTON" class="textboxesstyle" value="Upload photos and continue" DISABLED></FORM>
                        <br> </td>

<..>

if this doesn't make sense visit the link above and check it out in full.

Thanks in advance !!

Chris

(i mis-directed my question so there's an additional 250 pts in a question under a different section.)
0
garfield1979
Asked:
garfield1979
  • 3
  • 3
  • 2
1 Solution
 
KenAdneyCommented:
You should be able to javascript on the same page as long as it is inside <script type="text/javascript"></script>.

0
 
garfield1979Author Commented:
Ken,

I know i can use javascript on the page as well, but the button i am trying to control also calls to a VB function, the items i'm trying to run a check on are not within a <FORM> because if i put them in a form it will not work properly (because of the call to VB).

thanks for your answer :-)
0
 
KenAdneyCommented:
Sorry, I should have paid more attention.  Can you do it with ASP in an IF/THEM, something like:

IF albumcreate <> "" THEN

Response.Write "<FORM><input name="UPLOAD" type="BUTTON" class="textboxesstyle" value="Upload photos and continue" DISABLED></FORM>"

ELSE...

?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
garfield1979Author Commented:
it's supposed to be dynamic

this is the page:
http://66.223.16.116/help.htm

thats why i'm using javascript.

What i'm trying to do is if the user selects an item from the dropdown box the text boxt next to the drop down disapears (and the contents are erased) and if they do nothing.. meaning they dont select an item from the drop down nor do they enter text into the box, then they can't press the button (it becomes disabled)..

so i can't put any of the items in a <FORM> because they are called by that VB script that handles the Active X component at the top (which doesnt load in the test page, but you can see it in the source code)

if you need more insight into what i'm trying to acheive you can IM me here:
Yahoo: garfield19791234
AIM: garfield1979123
MSN: g_man_0123456@yahoo.com
0
 
sc0rp10nCommented:
Hi garfield1979,

From what I understand, when a user types something in the textbox, but then change their mind and select another option, then you want to hide the textbox and delete any text and disable the Upload button. Also that you don't really want to use javascript functions.

Well, here is one way of doing it.

- change the onChange value of the select item to the following:
onChange="javascript:document.getElementById('new_album').style.display=selectedIndex<1?'inline':'none';document.getElementById('albumcreate').value=selectedIndex>0?'':document.getElementById('albumcreate').value;document.uplfrm.UPLOAD.disabled=true"

- change your onKeyUp event trigger to the following:
onKeyUp="javascript:document.uplfrm.UPLOAD.disabled=this.value.replace(/\s+/,'')=='';"

- set the name of the form which contains the upload button. so it should be like
<FORM name="uplfrm">
      <input name="UPLOAD" type="BUTTON" class="textboxesstyle" value="Upload photos and continue" DISABLED>
</FORM>



let me know if this works
HTH.
0
 
garfield1979Author Commented:
Awesome, that worked ..

There is still one other thing that happens, if i don't select any photos to upload, it'll still act like it's uploading something, do you know of a way to verify that a user has selected pictures through that activex component ?

if not its cool, i'm still giving you the points. there's 250 more points on another question, if you post the same answer to that i'll give them to you as well.
http://www.experts-exchange.com/Web/Q_20951750.html

btw.

in the select box i had to make "Disabled=false" ('albumcreate').value;document.uplfrm.UPLOAD.disabled=true"

works perfect

thanks again !

Chris
0
 
sc0rp10nCommented:
Hey garfield1979,

Well, If the list box is empty, the upload event is disabled (when you right-click in the list box). The page that you've referenced (http://66.223.16.116/help.htm), doesn't allow me to click the upload button if no images are selected.

Also, thx for the points. I've posted the above solution in your other post.

thx again
AJ
0
 
sc0rp10nCommented:
garfield1979,

just make sure that the activex component's methods allow to check if there are any image(s) selected. So basically if there are no image(s) attached, then disable the the button.

hth
aj
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now