PDF Form Date Calculations and Restrictions? - javascript

I have made a PDF Form, I still have the following tasks to be done, any help will be useful:
Date Picker: Is there any Hijri/Gerogian Datepicker known to work on PDF Forms.
Date Compare: I have to date fields, want to validate the the end date field to be equal or more than the start date.
Calculate Date: Want to calculate the number of days between two dates.

Related

How to compare dates in react.js when I am using react-calendar for selecting dates?

I am using react-calendar to select first_date and last_date. I want to show the date in mm/dd/yyyy format when dates are selected. Later on, after selecting dates, I want to compare whether the last date selected comes after the first date. I am using Intl.DateFormat() function in react-js to format date in mm/dd/yyyy format but it is returning date in dd/mm/yyyy format.
Is there any other way to achieve this functionality?

Cleanest Way to Take A Date and Time Input And Create a Date (Javascript)

I would like to know the simplest way to get the date and time values from two html inputs, type="date" and type="time" pickers respectively. I want to merge into one complete Date string, I see I can
new Date(typeDate) -> date with gmt
but cannot
new Date(typeTime) -> invalid date
what is the simplest operation, ideally with utcString to maintain the timezone. Bonus is how to handle time without Date input and create a date.

Form date validation in a form

I have a form with 2 fields, in one of theme the user will enter a date in the format dd/mm/yyyy and in the other the user will enter a time in the format hh:mm
How can I force this fields formats and how can I validate the date field in order to make sure the date entered is valid and its bigger then the current date and the time field in order to make sure it's a valid time.
I'm using JavaScript in this web site.
For dd/mm/yyyy use
< input type=date>
For hh:mm:
< input type="time">
Set a processing function on form's onsubmit field. In that function you can get a value of dates ( with help of document.getElementBy* functions ) and compare them with DateTime object( use default constructor to get current date).

Validating two date-time local fields by earlier date?

I'm currently having a problem. I have two date-time fields a Start Date and an End Date. If i pick a date on the Start date for example October 2,2016 and pick a date on the End date October 1,2016 an alert dialog box should appear that the end date is earlier than the Start Date. How do i validate this via script? Sorry i am still very new to programming.
try this datetime lib, it has such function
http://momentjs.com/docs/#/query/is-after/
it shoud be something like
if (moment(dateBefore).isAfter(dateAfter)) {do somth}

how to validate and add date using jquery

I am working on a health website.
I am having a field called Last Menstrual Period, its a textbox which has to be filled in by doctor in format of YYYY-MM-DD.
What I want to do is, I have to add 281 days into the LMP date that the doctor will be entering in order to generate the Expected Delivery Date (Child Birth)
So I need followings thing to do:
The date entered should be in format of YYYY-MM-DD
It should be a valid date i.e. taking care of leap years and invalid dates like 2013-02-31 etc.
After generating the Expected Date of delivery (based on LMP that is entered), it should be displayed on screen.
As soon as the date is entered in the LMP textbox, these validations should be performed and the Expected Date Of Delivery is displayed inside a tag below the LMP textbox
How can I do that? Here is what I have tried so far.
// Calculate Expected Date Of Delivery
$('#lmp_date').change(function()
{
var lmp_entered = $this.val();
if(lmp_entered)
{
// $('#edd').html('1');
}
else
{
// $('#edd').html('Please enter last menstrual date to calculate EDD');
Please help me how to implement these validations and display the date using jquery. I am a newbie in jquery so dont know much about it. Any small help will be highly appreciated.
for validation I don t recommend using another library especially for such a simple rule. if the rule is so strict just write your own and use it site wide.
For example block non-numberic entries to textbox and add dash "-" by your code in every 5th and 9th chars.
Then to validate check the length of text and dashed, use split to get year. month and day separately and convert it to date with Date(txtYear,txtMonth,txtDay) if your date's year, month and day are equals to your txtYear, Month and Day then it means it s a valid date. After that use the below to calculate birth date.
just use Date constructor like below
var delDate = new Date(year, month, day + 281)
Just don t forget months start 0 in JS so Jan = 0, Feb = 1 etc.

Categories