Solved

VBScript Form Validation

Posted on 2004-04-12
8
11,109 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to translate path in URL with PHP? 11 48
Visitor to Web site (Log showing Strange IP Address) 9 124
Examples of Web API, REST web services and SOA 7 384
Microsoft Edge 9 106
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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…

749 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