Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stop Submit

Posted on 2002-04-08
9
Medium Priority
?
521 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 300 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

704 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