inputEx - DateField Usage

Basic DateField creation

Use the following code to create a basic inputEx DateField.

new YAHOO.inputEx.DateField({parentEl: 'container1', value: new Date(), showMsg: true});

Change date format

Set the formatDate to your localized date format ! Here is the french format :

new YAHOO.inputEx.DateField({dateFormat: 'd/m/Y', value: '03/27/2008', parentEl: 'container2', showMsg: true});

Updated event and return value

The DateField returns a javascript Date object instance :

var exampleDiv = YAHOO.util.Dom.get('container3'); var dateField = new YAHOO.inputEx.DateField({value: new Date(), parentEl: exampleDiv, showMsg: true, required:true, typeInvite:'m/d/Y'}); dateField.updatedEvt.subscribe(function() { exampleDiv.appendChild( inputEx.cn('div', null, null, dateField.getValue()) ); }); var button1 = inputEx.cn('button', null, null, 'setValue()'); exampleDiv.appendChild(button1); YAHOO.util.Event.addListener(button1, 'click', function() { dateField.setValue("06/10/1984"); }); var button2 = inputEx.cn('button', null, null, 'getValue()'); exampleDiv.appendChild(button2); YAHOO.util.Event.addListener(button2, 'click', function() { alert(dateField.getValue()); });