Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date validation plugin without calendar

We're launching a new content management system and redoing our user input forms in a way that allows the marketing department total control over what is displayed, in what order etc. I really want to use the jquery ui datepicker plugin because we can basically plug in its validation rules directly into the CMS, allowing for a fully customizeable control without any dev input. I've showed it off and shown how easy it is to configure.

Our current forms use three different drop downs, one each for day, month and year. There are a few people who aren't budging on moving away from this look/feel. We've all seen them, one of these guys:

<select>
    <option value="">-- Month --</option>
    <option value="1">Jan</option>
    <option value="2">Feb</option>
    <option value="3">etc.</option>
</select>
<select>
    <option value="">-- Day --</option>
    <option value="1">1</option>
    <option value="2">etc.</option>
    <option value="31">31</option>
</select>
<select>
    <option value="">-- Year --</option>
    <option value="etc.">etc.</option>                        
</select>

I can implement this, no doubt. What I don't want to do is write and maintain a javascript library that translates rules from a CMS into js inputs -- there has to be a better way.

I've shown them the month/year drop down selectors in the jquery ui plugin: http://jqueryui.com/demos/datepicker/#dropdown-month-year but they're still not buying it. Something about showing the days of the month... stakeholders.

What I want to know is if there is an existing configurable plugin that matches/rivals the jquery UI plugin in configurability and give the 3-select form factor. I'm making particular use of the mindate, maxdate (for different date ranges for different input types), and altformat options (to automatically translate the submission format that our backend expects). Sorry if my frustration is coming out... and thanks for the input.

Edit: just remembered there's a separate UI/UX area on stack exchange. My apologies if this is better suited over there - I don't have an account there yet.

like image 731
Patrick M Avatar asked Jul 26 '12 21:07

Patrick M


3 Answers

Going by your question title, you could look into datejs for all your date parsing, validation and incrementing.

http://code.google.com/p/datejs/

like image 61
James Westgate Avatar answered Oct 25 '22 08:10

James Westgate


I am not sure that there's already something perfectly suited for what you need.

You can however, use date-utils, which will simplify your validation. Here are some examples taken from the documentation:

Date.validateDay(day, year, month); // true/false whether a date is valid

d.between(date1, date2); // true/false if the date/time is between date1 and date2
d.isBefore(date); // true/false, true if this is before date passed
d.isAfter(date); // true/false, true if this is after date passed

d.toFormat(format); // returns date formatted with...
like image 36
Laurent Perrin Avatar answered Oct 25 '22 07:10

Laurent Perrin


What about this?

The link of the example is here.

like image 22
antoyo Avatar answered Oct 25 '22 09:10

antoyo