0

Hi In my form I have two input fields of date type, I want to set the second input value same as first one automatically, How can I solve this?

6
  • please show us a snippet of what you have tried up to this point Commented Feb 20, 2017 at 6:42
  • you can use clone() from jquery api.jquery.com/clone Commented Feb 20, 2017 at 6:43
  • @ÁlvaroTouzón - I do not think clone is useful here. An on keyup or similar Commented Feb 20, 2017 at 6:44
  • First clone, second put custom values Commented Feb 20, 2017 at 6:44
  • He has TWO input fields in the form. Why clone? Commented Feb 20, 2017 at 6:45

1 Answer 1

0

use jquery to put the value of first input field in the 2nd as the value of input1 is changed

$("#InputId1").keyup(function(){
    $("#InputId2").val(this.value);
});
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Thank you for the reply,
Here is my code <script> $(document).ready(function(){ $("#datetimepicker").keyup(function(){ $("#autofilldate").val(this.value); }); }); </script> </head> <body> <input id="datetimepicker" type="datetime-local" > <input id = "autofilldate" type="datetime-local" > </body>
because you are using datetimepicker so use change event beside keyup like $("#InputId1").change(function(){ $("#InputId2").val(this.value); });

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.