Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date input mask in Dojo

Does dojo have some kind of input mask capabilities, more specifically for dates, or is there a pure javascript solution that does the trick? Something along the lines of this jquery plugin.

like image 398
mfreitas Avatar asked Dec 21 '22 04:12

mfreitas


2 Answers

Yes, Dijit's DateTextBox will determine an appropriate format (mask?) for a Date based on the user's locale. You can override this using your own format (see datePattern) or choose between appropriate 'long' or 'short' formats (see formatLength)

There are other dijit.form widgets (variations of ValidationTextBox) which will constrain input for numbers and currencies. Also, you can use ValidationTextBox to specify your own regular expression, for things like telephone numbers or zip codes.

like image 51
peller Avatar answered Dec 24 '22 01:12

peller


The widget your looking for is called dijit.form.DateTextBox.

The functionality you are looking for is not called a mask in Dojo, it would be known as a constraint, and yes Dojo has support for a date range constraints. For example if you wanted to create an input field that had to be a date later than July of 2010 you could do something like this:

<input type="text" data-dojo-type="dijit.form.DateTextBox"
    data-dojo-props='{
            required: true,
            promptMessage:"After July 2010",
            constraints: {min:"2010-07-01"}
        }'
    />
like image 35
Caleb Avatar answered Dec 24 '22 01:12

Caleb