Welcome Guest Search | Active Topics | Sign In | Register

DatePicker Client Validation Options
Sunil
Posted: Saturday, August 23, 2008 11:19:04 PM
Rank: Member
Groups: Member

Joined: 1/6/2008
Posts: 13
I have 4 controls on the form. eo:DatePicker, TextBox and 2 buttons.
The buttons are for enabling and disabling eo:DatePicker control. I have written Click side JavaScript [OnClientClick] for both the button control to enable and disable the eo:DatePicker.

Code Snippet

function Diable()
{
var ctrl = document.getElementById('_eo_' + '<%=DatePicker1.ClientID%>' +'_picker');
var ctrl1 = document.getElementById('_eo_DatePicker1_popupimg');
ctrl.value = null;
ctrl.value = ctrl.defaultValue;
ctrl.disabled = true;
ctrl1.disabled = true;
return false;
}


function Enable()
{
var ctrl = document.getElementById('_eo_' + '<%=DatePicker1.ClientID%>' +'_picker');
ctrl.value = null;
ctrl.value = ctrl.defaultValue;
ctrl.disabled = false;
var ctrl1 = document.getElementById('_eo_DatePicker1_popupimg');
ctrl1.disabled = false;
return false;
}

.....
The issue here is if i select a date from datepicker control and then click on Disable button, the value should be empty and the control should be disabled. And when i click on Enable button, the value should be empty again and the control should be enabled. All these are working fine, but after enabling the control if i tab out from the eo.datecontrol to the text box the date value is retained in the eo.datepicker control. I dont want the date control to retain the date value. Hope fully my explanation is clear.
eo_support
Posted: Sunday, August 24, 2008 7:14:22 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,093
Hi,

You can't set the DatePicker's value like that. You would have to use our client side API to set it, because there are many other internal variables need to be updated as well. To use our client side API, you would first call eo_GetObject to get a calendar object:

http://www.essentialobjects.com/ViewDoc.aspx?t=clientapi_howto.html

Once you have the calendar object, you can call setSelectedDate on the object to set the selected date:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.Calendar.html

Thanks
Sunil
Posted: Sunday, August 24, 2008 8:57:42 PM
Rank: Member
Groups: Member

Joined: 1/6/2008
Posts: 13
Hi,

I have modified the code as per your suggestion, but still no luck. Can you pls check out.

function Enable()
{
var dtCtrl = eo_GetObject("DatePicker1");
alert(dtCtrl.getSelectedDate());
dtCtrl.disabled = false;
dtCtrl.setSelectedDate = null;
dtCtrl.value = null;
dtCtrl.VisibleDate = null;
alert(dtCtrl.getSelectedDate());

var ctrl1 = document.getElementById('_eo_DatePicker1_popupimg');
ctrl1.disabled = false;
return false;
}

Regards,
Sunil R
eo_support
Posted: Monday, August 25, 2008 6:28:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,093
Hi,

The key about the control is, you must follow the document to use it. This means:

1. You can not "invent" anything that does not exist in the documentation. For example, dtCtrl.disabled, dtCtrl.value, dtCtrl.visibleDate are all invalid because property "disabled", "value" and "visibleDate" does not exist;

2. You must use all the methods according to the documentation. For example, setSelectedDate is a method, not a property. So you need to use dtCtrl.setSelectedDate(null), instead of of dtCtrl.setSelectedDate = null;

The key is, eo_GetObject returns an object that only supports these methods:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.Calendar.html

Everything else that you do not see there would be your own "invention" and it will never work.

"disabled" is not available on the client side DatePicker object. If you wish to disable the DatePicker, you can set disabled to true on DHTML elements (just like what you did with _eo_DatePicker1_popupimg). Please keep in mind that, eo_GetObject and document.getElementById returns completely different things. So you should not mix them together.

Thanks
Sunil
Posted: Monday, August 25, 2008 8:39:57 PM
Rank: Member
Groups: Member

Joined: 1/6/2008
Posts: 13
Hi,

dtCtrl.setSelectedDate(null) resolved my issue. Thanks a ton Angel


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.