You are viewing limited content. For full access, please sign in.

Question

Question

What is this "now" object?

asked on October 28, 2021

$('#q7 input').attr('max', now.toISOString().substring(0,10));

 

This line of code works.  I modeled it off of something I read here.  Upon further research I cannot figure out why.  There is a method of the date object called Now (Date.Now()).  There is a (deprecated) jquery now() method ($.now()).  But, I cannot find any reference to a default Date object called "now".

Help me please... I don't have much hair left.
 

0 0

Replies

replied on October 28, 2021

Are you sure now is not just a var someone declared?

0 0
replied on October 28, 2021

It must have been declared by Forms or Parsley, 'cause it ain't in my code...

$(document).ready(function() {
  document.title = "Change Participant Status";
  $('#q14 select').focus();

  // set max exit date to today
  $('#q7 input').attr('max', now.toISOString().substring(0,10));
});

0 0
replied on October 28, 2021

But you said you got it somewhere else. I'm betting it is just a variable name that represents the current date. It has been orphaned.

 

0 0
replied on October 28, 2021

But the code works

0 0
replied on October 28, 2021

What type of field is q7?

0 0
replied on October 28, 2021

It's a regular date field.

0 0
replied on October 28, 2021

You are right now must be a variable defined in the form. It clearly returns the current date or date time in geek talk.

Looks like the line you have in your code sets the attribute of the date field for max date. Preventing someone from selecting a future date.

0 0
replied on October 28, 2021

Ah Hah!  It is an object created by Forms

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.