Vbscript

Results 1 to 8 of 8

Thread: Vbscript

  1. #1
    Join Date
    Dec 1969
    Posts
    76

    Default Vbscript

    I have a function writtten if VBScript which is being called on form submition.<BR>In this function I check the value of some text box if it is 1 I submit the form and if it is 0 then I don;t want to submit the form. <BR>Could you show me how stop this form from submitting if the value is 0.<BR>Thanks<BR>Vinay

  2. #2
    Join Date
    Dec 1969
    Posts
    89

    Default RE: Vbscript

    Your problem needs a workaround..<BR><BR>Let the form get submitted....then check the values of the text box..<BR>if not as per your requirements then<BR> ...redirect back to the form<BR>else<BR> ...process the submit<BR><BR><BR>this should have the same effect as the non submission...<BR><BR>Did you receive my earlier mail re. autorefreshing pages with scrolling to the bottom???

  3. #3
    Join Date
    Dec 1969
    Posts
    76

    Default RE: Vbscript

    But if you redirect the values of the text boxes would be wiped out. Which I don;t want.

  4. #4
    Nathen Grass Guest

    Default RE: Vbscript

    Since you&#039re using VBScript you can be pretty sure that all of the users will be using IE. You can make your submit button of type &#039button&#039 and not &#039submit&#039 and have a script triggered by the onclick event for that button. In the onclick script just make a call to the function that validates and call the submit method on the form if the value is 1.<BR><BR>i.e.<BR><BR>&#060;form id=&#039formID&#039 action=&#039something.asp&#039 method=&#039post&#039&#062;<BR><BR>&#060;!-- Form Contents Here --&#062;<BR><BR>&#060;input type=&#039button&#039 name=&#039btnSubmit&#039 value=&#039Submit&#039 onclick=&#039checkForm()&#039&#062;<BR>&#060;form& #062;<BR><BR>&#060;script language=&#039VBScript&#039&#062;<BR>Function checkForm()<BR>&nbsp;&nbsp;Dim intTemp<BR><BR>&nbsp;&nbsp;intTemp = checkTextBox() &#039This is you validation function<BR><BR>&nbsp;&nbsp;If intTemp = 1 then<BR>&nbsp;&nbsp;&nbsp;&nbsp;formID.submit() &#039Call submit method of form<BR>&nbsp;&nbsp;Else<BR>&nbsp;&nbsp;&nbsp;&nbs p;msgbox("Invalid value in text box.")<BR>&nbsp;&nbsp;End If<BR><BR>End Function<BR>&#060;/script&#062;<BR>


  5. #5
    Join Date
    Dec 1969
    Posts
    76

    Default RE: Vbscript

    Here is my function but now this does not submit the form, once I change the intput type to button.<BR><BR>&#060;script language = vbscript&#062;<BR>function chValue()<BR> start = timevalue(document.form1.stime.value)<BR> finish = timevalue(document.form1.ftime.value)<BR> if start &#062; finish then<BR> msgbox "Error",,"Error"<BR> else<BR> form1.submit()<BR> end if<BR>end function<BR>&#060;/script&#062;<BR><BR>Thanks for your Help

  6. #6
    Nathen Grass Guest

    Default RE: Vbscript

    Try changing <BR><BR>form1.submit()<BR><BR>to <BR><BR>document.form1.submit()<BR>or<BR>document. all.form1.submit()

  7. #7
    Join Date
    Dec 1969
    Posts
    76

    Default RE: Vbscript

    None of them are working

  8. #8
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Vbscript

    &nbsp;<BR> Hi Vinay<BR><BR> Let the form gets submitted first and check for 0 or 1<BR> if it is 0 then redirect else leave it..<BR><BR> now before submit you should store all the values entered in the form in hidden fields so that when redirect happens whatever data you entered won&#039t get disappear..<BR><BR>Arvind.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •