jonthornton / Datepair.js

A javascript plugin for intelligently selecting date and time ranges, inspired by Google Calendar.
https://www.jonthornton.com/Datepair.js
359 stars 85 forks source link

Validation and events #2

Closed jonthornton closed 10 years ago

jonthornton commented 10 years ago

After each user action, validate the date/time range and emit a javascript event to indicate status:

xdmx commented 10 years ago

The rangeSelected would help me really really a lot.

In my scenario I use only the start date, start time and end time fields, and I need to calculate the total minutes (end time - start time). I don't have any end date because it's the same of the start date (and cannot be changed)

jonthornton commented 10 years ago

@xdmx rangeSelected has been added. Let me know how it works for your use case.

xdmx commented 10 years ago

There may be a bug.. I have been able to select 2/13/2014 5:00am to 2:00am 2/13/2014, getting as result "Valid range selected", but it's a negative value (-3h). Shouldn't it return that it's invalid (having the end datetime before the start datetime)?

jonthornton commented 10 years ago

Haven't added the rangeError event yet, so no validation is being done yet - it's just checking complete/incomplete. I should have the validation done later today/tomorrow.

xdmx commented 10 years ago

:+1:

xdmx commented 10 years ago

It works perfectly, thank you!