Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
Read a date from textbox1 and show next date in textBox2

Below is my code, please advise where I am making a mistake . Textbox2 does not show anything. code for textbox1:-

<td>


                        @Html.EditorFor(model => model.DailyRegister.Date, new { htmlAttributes = new { @class = "form-control", required = "required", @id = "date1",@onchange="addDates2()" } })
                        @Html.ValidationMessageFor(model => model.DailyRegister.Date, "", new { @class = "text-danger" })
                        <script>
                                function addDates() {
                                document.getElementById("date1").value = document.getElementById("StartDate").value;
                            }
                        </script>
                    </td>

code for textBox2    

<td>
    
                            @Html.EditorFor(model => model.DailyRegister.Date, new { htmlAttributes = new { @class = "form-control", required = "required", @id = "date2" } })
                            @Html.ValidationMessageFor(model => model.DailyRegister.Date, "", new { @class = "text-danger" })
                            <script>
                                function addDates2() {
                                    
                                       var prev=document.getElementById("date1").value 
                                       var neww= prev.setDate(prev.getDate() + 1);
                                       document.getElementById("date2").value = neww; 
                                }
                            </script>
                        </td>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After doing my research , below is the answer to this scenario with details in comments.

    <script>
                        function nextDate3() {
                            //Date object us work with dates. By default js will use browser's time zone and display a date as a full text string.
                            var prev = new Date(document.getElementById("date2").value)
                            var nextDay = new Date(prev);
                            nextDay.setDate(prev.getDate() + 1);
// SetDate() sets the day of the specified DATE and getDate() returns the  day from the specified DATE
                            document.getElementById("date3").value = nextDay.toDateString();
//toDateString() method returns only date portion of a Date object as a String
                        }
                    </script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda