Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem to compare dates with DateValue 1

Status
Not open for further replies.

jck1

Programmer
Feb 22, 2006
8
US
Hi,
I got a asp page where I am trying to do validation of fields using VBSSCRIPT. In one of the validation I need to compare date field. The date field is captured as month, day and year (mm, dd, yy) where each of this entity is entered in separate text box.
There is a date named quarter date. The following is the code for validation. However, it is not working. I would like to know what is the problem in the following. Thanks.

<script LANGUAGE="VBScript">
Function frm_Details_OnSubmit

validation = true

If (frm_Details.ClaimNo_0.value = "") Then
Alert("You must enter a value for Claim number.")
frm_Details.ClaimNo_0.focus
frm_Details_OnSubmit =False

ELSEIf DateValue((document.frm_Details.ExpMonth_0.value) & "/" & (document.frm_Details.ExpDay_0.value) & "/" & (frm_Details.ExpYear_0.value)) > DateValue("(Session("QuarterEndDate"))") Then
Alert("You must enter claim date within the End Quarter Date")
document.frm_Details.ExpMonth_0.focus
frm_Details_OnSubmit =False


Else
frm_Details_OnSubmit = True
End If
End Function
</script>
 
You may try to play with the DateSerial function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
[tt]
Function frm_Details_OnSubmit

validation = true '[blue]what for?[/blue]

If (frm_Details.ClaimNo_0.value = "") Then
Alert("You must enter a value for Claim number.")
frm_Details.ClaimNo_0.focus
[red]window.event.returnvalue[/red] = False
ELSEIf DateValue((document.frm_Details.ExpMonth_0.value) & "/" & (document.frm_Details.ExpDay_0.value) & "/" & (frm_Details.ExpYear_0.value)) > DateValue("[red]<%=[/red]Session("QuarterEndDate")[red]%>[/red]") Then
Alert("You must enter claim date within the End Quarter Date")
document.frm_Details.ExpMonth_0.focus
[red]window.event.returnvalue[/red] = False
Else
[red]window.event.returnvalue[/red] = True
End If
End Function
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top