user3152496
user3152496

Reputation: 3

Jquery can't get the value from input form

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

Upvotes: 0

Views: 920

Answers (1)

Dave Zych
Dave Zych

Reputation: 21887

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>

Upvotes: 3

Related Questions