Solved

VBScript Form Validation

Posted on 2004-04-12
8
11,098 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Forbidden errors 5 124
selectSingleNode in Access 2013 11 53
CSS HELP 6 84
Windows Tool to Build Android and iOS App 3 54
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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 count occurrences of each item in an array.

896 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

14 Experts available now in Live!

Get 1:1 Help Now