Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Stop Submit

Posted on 2002-04-08
9
Medium Priority
?
523 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

916 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