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?
-
please show us a snippet of what you have tried up to this pointLaazo– Laazo2017-02-20 06:42:49 +00:00Commented Feb 20, 2017 at 6:42
-
you can use clone() from jquery api.jquery.com/cloneÁlvaro Touzón– Álvaro Touzón2017-02-20 06:43:30 +00:00Commented Feb 20, 2017 at 6:43
-
@ÁlvaroTouzón - I do not think clone is useful here. An on keyup or similarmplungjan– mplungjan2017-02-20 06:44:22 +00:00Commented Feb 20, 2017 at 6:44
-
First clone, second put custom valuesÁlvaro Touzón– Álvaro Touzón2017-02-20 06:44:51 +00:00Commented Feb 20, 2017 at 6:44
-
He has TWO input fields in the form. Why clone?mplungjan– mplungjan2017-02-20 06:45:11 +00:00Commented Feb 20, 2017 at 6:45
|
Show 1 more comment
1 Answer
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);
});
3 Comments
Gopikrishn
Hi Thank you for the reply,
Gopikrishn
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>
RAUSHAN KUMAR
because you are using datetimepicker so use
change event beside keyup like $("#InputId1").change(function(){ $("#InputId2").val(this.value); });