ninja forms giving restrictions on Datepicker - javascript

I have the ninja forms plugin in my wordpress website for a tailor made tour form. In that form there's a datepicker.
Recently it has started to give me an error when i select the dates. I can only select the dates before current date and two days after current date. When I select a date after the current date (eg: current date- 10/05/2018 | selecting date- 23/05/2018) it gives me the message "Please enter a valid date!" which is considered to be a blocked date.
I googled the heck out of this and still couldn't find a solution. Could someone please help me to resolve this issue?

I had the same issue and ended up changing the Format setting of the field from "Default" to "DD/MM/YYYY". Some sort of bug in Ninja Forms I guess. I haven't had time to dig into why yet, so if anyone has a clue, let us know.

Related

I need to make a Google form available for a specific time each day

We have a Google form that we would only like to be made available to users at a specific time each day. It should only be open from 2:00 to 2:15, Monday thru Friday. Wasn't sure if the following would work:
FORM_OPEN_DATE =
FORM_CLOSE_DATE =
Not exactly sure of the value to place after the = sign. Looked the JavaScript Date objects but could not find a one that I thought would work.
There is no built-in functionality to do that. In order to do that you can go with Date API.

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();

Date/Time on Articles <time>

This is a fairly simple question. While I'll certainly accept and appreciate a detailed answer, guidance in the right direction is all I'm looking for as I have no qualms about learning. I still consider myself an amatuer so please forgive me if you find this trivial.
I'm sure you've all seen what I'm looking for here if you've read a blog or any type of news site. Articles usually have some type of heading with "1 Year Ago", "28 Minutes Ago", etc to reflect the difference in time from when an article was published to the current time you are looking at it. What I'm trying to figure out is how that is accomplished?
I learned today that a tag exists but so far I haven't been able to determine how the attributes you can assign to (e.g. datetime="2015-04-27 20:00") it turn into a readable "1 Year Ago". In my head, I'm imagining some ways I might be able to do this with JavaScript but I'm wondering if this is how it's typically done.
Thanks in advance.
What you might have read is that the "special attributes" actually are pseudo-attributes in some front end framework like Angular, React or Vue etc.
In angular they are known as custom directives. Where you can define custom attribute to pass some data into angular code and get some thing back in this case the humanized form of a date.
What you probably want is moment.js and some way to pass the the date into moment.js to parse it if your not using Angular or other frameworks. Since you are nt so descriptive about your code behind I leave it here on how to work that thing out.
A simple example to demonstrate Moment.js Time from now
moment([2007, 0, 29]).fromNow(); // 4 years ago

angularjs $valid on dates reports incorrectly in firefox

I have noticed an issue with form validation on dates within firefox, that I would greatly appreciate any advice or a usable work-around for.
Date Validation Problem
I am using angularjs v1.3.11, and the issue i'm experiencing is actually with the bootstrap datepicker, however it is the same issue for a standard input type="date" field.
If I put an invalid leap day e.g. 29/02/2013 (en-GB date - DD/MM/YYYY) into a text field using bootstrap datepicker or an input type="date" field $valid on that form field reports as invalid on ALL browser accept for firefox. I really want it to report as invalid on every browser!
It appears to invalidate a date, if I for example put complete garbage into the field such as entering a date without a month so 29/2013 would quite rightly report as invalid in all browsers I've tested. It's almost as if angular is running a special regex for firefox that doesn't care about the validity of a date other than that it has 3 sets of numbers in it.
Viewing this date issue on the angular website
If you select the following link https://code.angularjs.org/1.3.11/docs/api/ng/input/input%5Bdate%5D you will be taken to angulars own write up of input[date].
Follow the link in firefox - scrolling to the bottom of the page to the example they've put on the screen and type in an invalid date such as 29th February 2013 (It seems to need ISO date format for firefox on this site) and you will see it report the date youv'e entered as valid, even though there is no 29th February in 2013 as it was not a leap year.
If you perform the same test in chrome for example, then you will see it report the date as INVALID - which is what I wish to happen.
How to resolve this?
Thankyou if you've managed to read this far! I realise that this may be an issue with how a particular browser deals with dates, although i've searched far and wide and haven't found any listed bugs for this in either firefox or angular.
What i'm really hoping here, is that someone may know a work-around, for example a way of intercepting the call that determines $valid on an input field, so that I can run my own regex or something like that. If anyone know's why this is so strange in firefox i'd love to know that too!
Thanks in advance for any help anyone can offer :)
Lindsay
You need more sophisticated date logic to determine if a date is valid. I suggest using a third party library like moment.js or date.js to perform the date validation logic.
Try the demo link at the bottom of the accepted answer for the following SO question:
Simple angularjs date input
Enter 2013-02-29, it will correctly identify the date is invalid.
Tested on Firefox, IE, and Chrome.

How to detect date format defined by browser?

I'm using HTML5 input type=date field and because some browsers still don't support this feature, I would like to create error validation message for browsers that display just normal text field instead of date field. This error message should look like
Please enter date in format: ...
But I need to find the correct format, that the browser is set to. Is there any php/js/jQuery way how to find out this?
Thanks to #Jose Vega's answer I was able to find very easy way how to do it.
var now=new Date(2013,11,31);
var str=now.toLocaleDateString();
str=str.replace("31","dd");
str=str.replace("12","mm");
str=str.replace("2013","yyyy");
Error message:
"Please enter date in format:" + str
I have used the globalize library to do something similar. I don't know if its functionality has what you are looking for, but I know it does a good job handling different cultures. I use the window.navigator.userLanguage to determine culture and then feed it to the globalize library to do its thing. I've had success when dealing with currency and numbers.
EDIT: See if this helps:
var now=new Date();
alert(now.toLocaleString());
taken from How format JavaScript Date with regard to the browser culture?
Reference Displaying proper date format depending on culture
Why not to allow users to enter date in any format they like.
E.g. i am tourist in the USA and the browser says me to use format mm/dd/YYYY instead of my native dd.mm.YYYY.
Just get any date entered by users and parse it with Date.parse()

Categories

Resources