Jump to content

Validating date period


sugoi_kat

Recommended Posts

The user can view a report during a specific period by specifying the starting and ending date. What I want to do is check that the ending date of the period they specify isn't less than the start date. The code below is the current function i'm using to check that the period is valid. It takes values from the textbox on the page and compares the two dates and if the starting period is greater than the ending period, then an alert message appears. However, it doesn't seem to work. Am I doing this correctly? :)

function checkDate(){    var dStart = document.stu_comp_ex_report.startDt.value;    var dEnd = document.stu_comp_ex_report.endDt.value;    if (dStart > dEnd)     {        window.alert("Make sure the start period is before the ending period");    }    else    }        if (dStart = null || dEnd = null)        {            window.alert("Please ensure that the starting period and the ending period are stated");        }    }}

Link to comment
Share on other sites

hi i corrected the brackets,but it's still not checking the the date any ideas? by the way i forgot to mention that this code should have executed when a button is pressed to recalculate data in the report

how do you have the button set up?LG
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...