Solved

Stop Submit

Posted on 2002-04-08
9
511 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Field that has HTML displays the code instead of the text in html 16 94
API works for 1 result, need to make it many 30 92
html Uncheck Checkbox 2 25
ASP exit 10 19
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 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