magopian / att

ATTESTATION DE DÉPLACEMENT DÉROGATOIRE
https://magopian.github.io/att
33 stars 9 forks source link

Autofil date with JS #4

Closed xgaia closed 4 years ago

xgaia commented 4 years ago

Hello @magopian , Cool project.

I suggest to auto fill the date field with a little javascript

<script type="text/javascript">
          var today = new Date();
          var mm = String(today.getDate()).padStart(2, '0');
          var dd = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
          var yyyy = today.getFullYear();

          today = mm + '/' + dd + '/' + yyyy;
          document.write(today);
</script>

I can make a PR

magopian commented 4 years ago

I thought about it, and yes it might be a useful addition. We need to make sure though that this value is stored in the localStorage, even if the user never updates it!

Regarding the PR, sure, thanks! A heads up: I believe it should set the value of the date input

sunny commented 4 years ago

Perhaps this shouldn't actually be a field, but stay up to date automatically?

magopian commented 4 years ago

Closing following my comments in #10