最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Date validation plugin without calendar - Stack Overflow

programmeradmin4浏览0评论

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: 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 ing 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.

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./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 ing 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.

Share Improve this question asked Jul 26, 2012 at 21:41 Patrick MPatrick M 11k9 gold badges74 silver badges104 bronze badges 5
  • 1 I think this belongs here, it seems more coding than design... – Charlie Commented Jul 26, 2012 at 21:45
  • While it's monly unwise to tell stakeholders 'no', you CAN make them aware of the costs/implications of their decisions. Tell them how long it will take you to correctly code and maintain the 3 selects vs. how long it will take to implement the datepicker. – Dan Pichelman Commented Jul 27, 2012 at 14:04
  • I read this topic twice and I don't fully understand what it is you are trying to do and how the current answers are not giving you satisfying results. Can you provide more feedback into your actual scenario ? – Khez Commented Aug 3, 2012 at 11:46
  • try Yahoo ui: yuilibrary./yui/docs/calendar/calendar-multipane.html – Ruben Commented Aug 3, 2012 at 13:49
  • @Khez Just an hour before your ment, there was exactly one answer :-) I'll try out a few of these suggestions and see if I can share something close to what I want in a jsfiddle. – Patrick M Commented Aug 3, 2012 at 15:08
Add a ment  | 

4 Answers 4

Reset to default 2 +50

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

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

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...

What about this?

The link of the example is here.

You can try mobiscroll which will still provides all the features of drop-down like feel without promising on looks .

发布评论

评论列表(0)

  1. 暂无评论