Created
March 24, 2020 19:30
-
-
Save brunolimadevelopment/b382c335ba4e2c481c6428a7d0cc4bf2 to your computer and use it in GitHub Desktop.
[JS] - INSERINDO DATA ATUAL NO CAMPO DO FORMULÁRIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CRIA OBJETO DATA - JS | |
var data = new Date(); | |
var dia = data.getDate().toString(); | |
var diaF = ( dia.length == 1 ) ? '0' + dia : dia; | |
var mes = ( data.getMonth() + 1 ).toString(); | |
var mesF = ( mes.length == 1 ) ? '0' + mes : mes; | |
var anoF = data.getFullYear(); | |
var data = diaF + '/' + mesF + '/' + anoF; | |
var elFiled = document.getElementById('data'); | |
elFiled.setAttribute('value', data); | |
// HTML | |
<input type="hidden" name="data" id="data"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment