Is there a way to cancel the formatting of an invalid date with the webdatechooser? When a user enters an invalid date, I would like to display a message rather than reformatting it for them. I have the InvalidDateEntered event handled on the client side, but there does not seem to be a way to cancel the formatting without modifying the script files the control uses.
Thank you,
Chad
Hi Chad,
It is correct default behavior of WebDateChooser to restore last good date in case of invalid date. To modify that you need to use internal objects. If you may look at implementation of ig_webdropdown.js then you may find members "date" and "editor.good". If you set them to nulls, then last "good" date will be disabled. Unfortunately in case of misbehavior there is no support for usage of internal variables.
function WebDC_InvalidDateEntered(oDateChooser,oInvalidEventArgs,oEvent){ oDateChooser.date=null; oDateChooser.editor.good=null; //alert('invalid date'); //oDateChooser.date = new Date(....);}
Hi, Am i missing something, this doesnt seem to work.
dteCtrl.ClientSideEvents.InvalidDateEntered = "InvalidDateEntered"
My Javascript function is as follows:
oDateChooser.setValue(null);
oDateChooser.date=null;
alert("hello");
}
The Function is being called but the value of the field is still being set to the First good date. I am using v8.2. How can I disable this functionality of first good date?
Regards
Chris
Hi Chris,
I can not explain or reproduce that. If you process InvalidDateEntered, then to set null date, it is enough only 1 from the list of your statements.
I tried exact your codes and also tried to comment lines in function InvalidDateEntered. For example keep only 1st line (or 2nd or 3rd+4th lines). All cases worked exactly the same and generated null date.
Maybe I have missed something is the controls config...??
<form id="form1" runat="server">
<igsch:WebDateChooser runat="server" ID="wdcTest" AllowNull="true">
</igsch:WebDateChooser>
</form>
Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Inherits System.Web.UI.Page
If Not IsPostBack Then
wdcTest.MaxDate = New Date(2008, 2, 1)
wdcTest.ClientSideEvents.InvalidDateEntered = "InvalidDateEntered"
End If
End Class
function InvalidDateEntered(oDateChooser,oDate,oEvent){
alert("Nulled");
Interestingly the alert is popup up and i see the value of the date chooser as null and then i click the ok button on the alert and its reset.
Ideas?
Thanks
Chris, Chad, (or anyone else), were you able to get this working? I am having the same problem, except I am using ver 6.2.
I figured out the problem. If there's a window.alert in the js function, it has to be done AFTER setting the WebDateChooser to null. Otherwise, it won't set the value.