Solved

Stop Submit

Posted on 2002-04-08
9
512 Views
Last Modified: 2012-05-04
I have personal web server and IE6, I have a date validation function that will trigger when user click on the submit button. However if the date is invalid, a msgbox is displayed, and i wanna to stop the submit, but the fromname_onsubmit=false does not work. The result.asp still got executed..please help

<Script language = "VbScript">
     Function Validate(Request)
          msgbox request.fromdate.value
          If IsDate(Request.FromDate.value) = false then
               msgbox "Invalid Date"
               Request_onSubmit = False
          End if
     End Function
</Script>

<form Name="Request" Action="Result.asp" Method="Post" onSubmit="Validate(Request)">
<Input Type="Submit" Name="Submit" Value="Submit StoreNum">
<Input Type="Reset" value="Reset Form">

</form>
0
Comment
Question by:ysk9818
[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
  • 5
  • 2
  • 2
9 Comments
 
LVL 2

Expert Comment

by:kahwoo
ID: 6926878
try this

<Script language = "VbScript">
    Function Validate()
         msgbox document.Request.fromdate.value
         If not IsDate(document.Request.FromDate.value) then
              msgbox "Invalid Date"
              Exit Function
         End if
         document.Request.submit      
 
    End Function
</Script>

<form Name="Request" Action="Result.asp" Method="Post">
<Input Type="Submit" Name="Submit" Value="Submit StoreNum" onClick="Validate()">
<Input Type="Reset" value="Reset Form">

</form>



regards
kahwoo
0
 
LVL 2

Expert Comment

by:kahwoo
ID: 6926884
this is the correct one ( i missed a part)

<Script language = "VbScript">
   Function Validate()
        msgbox document.Request.fromdate.value
        If not IsDate(document.Request.FromDate.value) then
             msgbox "Invalid Date"
             Exit Function
        End if
        document.Request.submit      
 
   End Function
</Script>

<form Name="Request" Action="Result.asp" Method="Post">
<Input Type="button" Name="Submit" Value="Submit StoreNum" onClick="Validate()">
<Input Type="Reset" value="Reset Form">

</form>



regards
kahwoo
0
 
LVL 2

Expert Comment

by:kahwoo
ID: 6926898
a better practice would be as below
remember that "submit" is a keyword dun put it as a name
and "Request" is a collection in server side scripting  so please avoid using it. for both matter i had replace it like

submit - > butSubmit
request -> frmRequest


<Script language = "VbScript">
  Function Validate()
       msgbox document.Request.fromdate.value
       If not IsDate(document.Request.FromDate.value) then
            msgbox "Invalid Date"
            Exit Function
       End if
       document.Request.submit      

  End Function
</Script>

<form Name="frmRequest" Action="Result.asp" Method="Post">
<Input Type="button" Name="butSubmit" Value="Submit StoreNum" onClick="Validate()">
<Input Type="Reset" value="Reset Form">

</form>



regards
kahwoo
0
Technology Partners: 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!

 
LVL 2

Expert Comment

by:kahwoo
ID: 6926904
sorry this is the final ^_^

<Script language = "VbScript">
 Function Validate()
      msgbox document.frmRequest.fromdate.value
      If not IsDate(document.frmRequest.FromDate.value) then
           msgbox "Invalid Date"
           Exit Function
      End if
      document.Request.submit      

 End Function
</Script>

<form Name="frmRequest" Action="Result.asp" Method="Post">
<Input Type="text" maxlength="20" Name="fromdate">
<Input Type="button" Name="butSubmit" Value="Submit StoreNum" onclick="Validate()">
<Input Type="Reset" value="Reset Form">

</form>
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6926987
Have your Function Return "false" it the date is not Valid, and true if the data IS valid:

Function Validate()
     Validate = True
     msgbox document.frmRequest.fromdate.value
     If not IsDate(document.frmRequest.FromDate.value) then
          msgbox "Invalid Date"
          Validate = False
     End if
End Function


0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 100 total points
ID: 6926988
like this (you were quite close):

<Script language = "VbScript">
    Function Validate(Request)
         Validate = True
         msgbox request.fromdate.value
         If IsDate(Request.FromDate.value) = false then
              msgbox "Invalid Date"
              Validate = False
         End if
    End Function
</Script>

<form Name="Request" Action="Result.asp" Method="Post" onSubmit="Validate(Request)">
<Input Type="Submit" Name="Submit" Value="Submit StoreNum">
<Input Type="Reset" value="Reset Form">

</form>
0
 
LVL 2

Expert Comment

by:kahwoo
ID: 6926994
Arthur_Wood

correct my if i am wrong i belive that wouldn't make a differet
it will submit anyway

regards
kahwoo
0
 

Author Comment

by:ysk9818
ID: 6928258
I have to give credits for both of you kahwoo and Arthur_wood for giving me hint on this problem, however i can only assign the point to one person. both of you give me good advise and i thank for that. I awarded the point to arthur_wood because he gives me the idea to use function. so i create a frmrequest_onsubmit event and return false when the date is invalid. this solve the problem. below is my code. thank both of yall

Function frmRequest_OnSubmit
   If IsDate(frmRequest.FromDate.value) = false Then
     msgbox "Invalid Date"
     frmRequest_onSubmit = False
   End if
End Function

<form Name="frmRequest" Action="Result.asp" Method="Post" LANGUAGE ="VbScript">

0
 

Author Comment

by:ysk9818
ID: 6928260
refer to ysk9818 comment for complete solution. thank both of yall
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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
Select case on click 3 26
Cannot open file from ASP if user is "logged in" 13 32
Html value of radio 14 44
Ajax on ASP 2 36
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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