RobinHerbots jquery.inputmask date range - javascript

I am using RobinHerbots/jquery.inputmask library.
I need to make sure the date inputted in great than current date.
There is code for yearrange but I dont see anything for basic 'daterange'.
Using RobinHerbots/jquery.inputmask library, how can I make sure the date entered is greater than current/todays date new Date()?

There is an open issue about your question in the github of RobinHerbots/jquery.inputmask:
RobinHerbots answers that this feature will be implemented in 3.4 and that for now you can use the postValidation callback.
In the current date alias this is not implemented. However, you can use the postValidation callback to validate if the input is after the current date.
It would be a nice feature, and I will add it to the date alias in milestone 3.4

Related

Javascript or jquery validating the date of the application for the user to re apply again

I'm currently using dynamics CRM and adxstudio and I was wondering if there's some sort of jquery or javascript code I can use to validate the date of the application. So basically applicants can only re-apply within 4 weeks of their current application expiry date. I provided a screenshot of the list.This is the main list
The applicant is only allow to renew within 4 weeks of the Next Recert Date meaning they cant apply earlier nor later. I already have the id all I need to know is the function or an alert to give the user that they cant recertify yet.
Did you try Moment.js? It is an awesome JS library for date handling.
EDIT: Within the above link, you have many examples of data manipulation. You could use to parse and manipulate dates, like making sure today's date is within the range of [expiryDate - 4 weeks, expiryDate].
Example: moment(expiryDate).subtract(4, 'weeks').calendar();

difference between moment js functions and javascript date functions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Actually i am thinking about to use moment.js in my new project.because my new project is a employee working sheet application.
I read the moment.js documents.
We can get the current date by using the below code in moment.js
moment().valueOf();
We can get the current date by using javascript
new Date()
The both are giving same result. with same speed (so no performance issue )
also formatting, get methods and set methods are already has javascript. then why i go to moment.js?
Please give me some explanations about the difference's. And let me know which one is best for my new project.
Moment.js
A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
Reason why we use Moment.js - Many web applications today, especially social ones, deal with the concept of time. They are usually employed to sort events or posts, or to mark the moment in which something happens. You can think of your Twitter timeline or your GitHub news feed. JavaScript has a Date object that you can use to manipulate dates, but it often doesn’t have all you need in your web applications
The Moment.js library not only parses dates from strings, but it may also be used to validate, manipulate, and format dates. It supports internationalization, which is so important with dates, as well as human-friendly formatting like "Last Friday at 9:48".
These are all good things for sure, but today's order of the day is date parsing, so let's get into how that works.
Moment.js creates a wrapper for the Date object rather than extend it. To reference the wrapper object, simply call the moment() getter function. The Moment prototype is exposed through the moment.fn property, so you can add your own functions to it if you are so inclined.
Courtesy of
Managing Dates and Times Using Moment.js
A Roundup of Popular JavaScript Date Parsing Libraries: Moment.js
Moment.js is convenient when you want to manipulate Dates.
An Example for moment is given below
moment()
.add(7, 'days')
.subtract(1, 'months')
.year(2009)
.hours(0)
.minutes(0)
.seconds(0);
moment().endOf('day').fromNow();
But if formatting, getting and setting is all you need, you might not need a library for that.
Obviously, I would suggest to go with moment.js. It is one of the most popular Date parsing library.
moment.js has a various inbuilt function's available which is easy to use.
It will save your development time.
Manipulating and parsing dates is very easy.
It comes down to what you're trying to do.
MomentJS provides an API that pretty-much wraps the native Date object, which is why you call .valueOf. new Date is simply giving you the native Date objects (and to manipulate it using moment, you'd need to pass it to its constructor).
I would say general rule of thumb:
If you're creating a date for use on the site or as some kind of UI element, use Moment.
If you're storing a date back to a service layer, use Date.
If you're working in a method that's manipulating the date, use Moment; If that then needs to be passed to another service layer, call .valueOf and save it off.
Moment is great for the UX, but isn't a "standard" (and therefore wouldn't be ideal for serialization/storage).
Moment.js has a good support for adding, subtracting, advanced formatting, finding differences between two days. Also it has internationalization support so you can convert to any language very easily.
just like any library comes with a purpose to aid with something and make it easy to work. momemt.js makes working with dates PAINLESS.
working with dates considering the timezone and formats factors etc is very difficult, but moment.js makes it a breeze to work with dates.
read more here

In Moment.js, why doesn't subtract by 'week' work?

I'm using Moment.js and following line of code doesn't seem to actually do anything:
moment().subtract('week', 1)
In the documentation, it shows an example of subtract being used with 'days' but it doesn't specify that it's the only string you can use. In most of the other functions, it's an option where you can use 'days', 'weeks', 'months', so I'm not sure if I'm doing something wrong or 'weeks' just isn't supported:
Moment.js Subtract Documentation
Here's the example of subtracting days:
moment().subtract('days', 7);
It's also what I ended up using instead of 'weeks' but I'm still curious why 'weeks' aren't supported.
You have it backwards from the Moment API.
moment().subtract(1, 'week');
This is a bit old question but it appears that even back then it was relevant.
Definetely nowadays is even more relevant to consider parse.com moment.js version (1.7.2) to the current moment.js version (2.8.4) and the only API doc that parse.com makes reference to
Check an answer to this in a previous post in Trouble using the Moment module
I would suggest to work always with latest moment.js so you can properly work with the provided documentation (during my search I was not able to find 1.7.2 documentation.. beside you will miss many great features working with the version provided in parse.com.
Add the new version as indicated in the same post in the accepted answer.

Change timezone in Arshaw FullCalendar

From my understanding, Arshaw FullCalendar displays events according to the timezone of the local computer's operating system. I assume this is done by the javascript Date() object, which also is based on the local computer's operating system. I have an application that has group calendars and a group timezone, I want to be able to force every local Arshaw Calendar to display according to that group's time-zone, no matter what timezone that computer is. How do you do this?
Note: I've looked through the documentation fairly thoroughly, and found no such option. I'm hoping that javascript has something equivalent to php's date_default_timezone_set(), which seems to me the way this could be solved.
*Edit 1/31/2013 12:23pm CST:
I am sending everything to the calendar as unix timestamps, so I assume the option ignoreTimezone would not apply here, as described in this stackoverflow thread:
jQuery FullCalendar timezone synchronization
You should probably try to set the option "ignoreTimezone" to "false" and give to Arshaw FullCalendar date in ISO8601.
You can get more information about that here: http://arshaw.com/fullcalendar/docs/event_data/ignoreTimezone/
To convert unix timestamps to ISO8601, you can use this in javascript:
var d = new Date(1360412434000).toISOString();
This is ECMAScript 5.
See here for compatibility and fallback code: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toISOString

How to validate date in javascript

I have a SharePoint Date Picker Control which is used to select a BirthDate . I want the birthdate to be atleast 16years older from the current date.
Can anyone guide me how to validate this using javascript? I have not used javascript much, Please guide me how to go about the validation process?
Look at using the library date.js:-
http://www.datejs.com/
This library adds a number of methods for working with date objects.
Without using an external library, the easiest way to compare a date of birth is over 16 is to convert the date to an epoch timestamp and then compare this against a timestamp of now minus 16 years.
Be aware that while most languages/platforms use timestamps in seconds, Javascript uses milliseconds, so when comparing against timestamps from external sources, you need to divide by a factor of 1000.

Categories

Resources