You are browsing the archive for attr.

Changing the default value of Dojo DateTextBox

July 1, 2012 in Dojo, JavaScript

In some business use cases, you may need to change the default value of the Dojo DateTextBox. For example, if you have a date of birth field and you wish to make the default date a date in the past in order to minimize the user navigation in the Dojo DateTextBox component.

In order to change the default value of Dojo DateTextBox, you need to change the value attribute of the dijit.form.DateTextBox as shown below.

<label for="sampleDate">Select the Date: </label>
<input id="sampleDate" dojoType="dijit.form.DateTextBox"></input>

<script type="text/javascript">
	dojo.addOnLoad(function (){
		dijit.byId('sampleDate').attr("value", new Date(1970, 1, 30)); 
Skip to toolbar