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)); 
	});
</script>

One comment on “Changing the default value of Dojo DateTextBox

  1. Jeyaprakash on said:

    sir,
    can u tell me,is it possible to change the default value as empty

Leave a reply

Your email address will not be published. Required fields are marked *

308,543 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by sweet Captcha