0

This is all I want.

<form>
<input type="text" name="date" value="currentdate()">
.....</form>

Here I want to set default value as a current date.

Cup of Java
  • 1,769
  • 2
  • 21
  • 34
Kishor Tiwari
  • 101
  • 1
  • 7
  • 2
    http://stackoverflow.com/questions/1531093/how-to-get-current-date-in-javascript may help you – AMACB Jan 17 '16 at 01:04

3 Answers3

4

I don't think you can do that.

But this would work:

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
  dd='0'+dd
} 

if(mm<10) {
  mm='0'+mm
} 

today = mm+'/'+dd+'/'+yyyy;

document.getElementById('date').value=today ;
<form>
  <input type="text" name="date" id="date">
</form>

I got this solution from Samuel's answer in this post.

Community
  • 1
  • 1
Phiter
  • 14,570
  • 14
  • 50
  • 84
2

You can set a default value to a input, in the DOM, using the document.ready function:

$( document ).ready(function() {
    document.getElementById("myInput").defaultValue = myCustomFunction();});
1

While the question is really unclear and I would recommend an edit be done BY YOU, I will attempt it...

<form action="page.php" method="post">
<input type="text" name="date" value="Enter the date here!" /><br />
<input type="submit" name="submit" value="submit" />
</form>
.....

I dunno if this is what you want but if you want to pass it to a handler you'd need to Google form actions and change the first line's "action" attribute then delete the 'method="post"' part unless you want it.

(Note: The reason I feel like this is what you want is because you made the input a text area... Why would you do that if you want it to display the current date?)

insanewolfhd
  • 81
  • 1
  • 11
  • Eventhough it is text area, I want to pass default value as a result of some js function. Sorry, I don't know much about coding. – Kishor Tiwari Jan 17 '16 at 23:04