calandrelli
Technical User
I am very new to Javascript and I am having trouble getting a javascript function to work inside of an If...then statement. I downloaded a Javascript function called "DateInput" that produces a datepicker and it uses four variables ( Name, Required, Format, Default Date). I am using it on an ASP page returning a record that contains a date field. Placing this into the code works perfect if the date field is already populate (Date Field name = Due_Date)
The only issue I have is that when the date filed contains a zero length string the function does not work since the VBScript variable "Due_Date" no longer contains a valid date. I wanted to fix this problem by evaluating the "Due Date" field and then calling the function. If the date is not present then I could run the function with no default date picked and the DateInput function will default to today’s date...but the following does not work. It returns nothing.
Code:
<script>
DateInput('Due_Date', false, 'MM/DD/YYYY',"<%=Due_Date%>")
</Script>
The only issue I have is that when the date filed contains a zero length string the function does not work since the VBScript variable "Due_Date" no longer contains a valid date. I wanted to fix this problem by evaluating the "Due Date" field and then calling the function. If the date is not present then I could run the function with no default date picked and the DateInput function will default to today’s date...but the following does not work. It returns nothing.
Code:
<script>
If (Due_Date == ""){
DateInput('Due_Date', false, 'MM/DD/YYYY',"<%=Due_Date%>");}
else {
DateInput('Due_Date', false, 'MM/DD/YYYY');}
</Script>