Solved

VBScript Form Validation

Posted on 2004-04-12
8
11,096 Views
Last Modified: 2008-02-01
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
Comment
Question by:garfield1979
  • 3
  • 3
  • 2
8 Comments
 
LVL 10

Expert Comment

by:KenAdney
ID: 10826403
You should be able to javascript on the same page as long as it is inside <script type="text/javascript"></script>.

0
 

Author Comment

by:garfield1979
ID: 10826431
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
 
LVL 10

Expert Comment

by:KenAdney
ID: 10826498
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
 

Author Comment

by:garfield1979
ID: 10826569
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Accepted Solution

by:
sc0rp10n earned 125 total points
ID: 10838557
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
 

Author Comment

by:garfield1979
ID: 10841988
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
 
LVL 2

Expert Comment

by:sc0rp10n
ID: 10855639
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
 
LVL 2

Expert Comment

by:sc0rp10n
ID: 10855657
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
CSS HELP 6 74
Microsoft Edge 9 79
How do the JavaScript &&  !== operators work together? 3 39
Problem to page 4 21
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 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

13 Experts available now in Live!

Get 1:1 Help Now