Solved

Stop Submit

Posted on 2002-04-08
9
508 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 2

Expert Comment

by:kahwoo
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
refer to ysk9818 comment for complete solution. thank both of yall
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
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/…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

12 Experts available now in Live!

Get 1:1 Help Now