0

Why do I can't see the start and end value? What's wrong with the code below? It returns undefined value.

    Start Date : <input type="text" id="datepicker" name="start" id="start" style="width:450px;" /><br>
    End Date : <input type="text" id="datepicker2" name="end" id="end" onchange="compareDate()" style="width:450px;" /><p id="err"></p>

    <script>
       function compareDate()
       {
          var startDate = $("#start").val() ;
          var endDate = $("#end").val();
          var err = document.getElementById("err");
          document.getElementById("err").innerHTML = startDate + "///" + endDate;
       }


    </script>

I'm a newbie in jQuery. Please help me

1 Answers1

3

You have 2 id's in your input tags. Remove the first one in each:

Start Date : <input type="text" name="start" id="start" style="width:450px;" /><br>
End Date : <input type="text" name="end" id="end" onchange="compareDate()" style="width:450px;" /><p id="err"></p>
Dave Zych
  • 21,581
  • 7
  • 51
  • 66