1

my concept is to type something in one input and at the same time that value will print in another field. all fields are working except date. I am using bootstrap datepicker to display date. I am helpless to display date on another field. please help me with the same. Below is my code to display normal text and date too.

<div class="control-group">             
     <label class="control-label">Address:</label>
     <div class="controls">
        <input required type="text" id="c7"  class="span2 insert">      
     </div>
</div>

id c7 is using to display text in below span

Address:<span class="rc7"></span>

script for this:

$('input').keyup(function(){
    var id=$(this).attr('id');
    //alert(id);
    var na=$('#'+id).val();
    $('.r'+id).text(na);        
    //alert(id+na);
});

date html code

<div class="control-group">                 
<label class="control-label">Date:</label>
<div class="controls input-group date">
    <input type="text" class="span2 insert angular_input" id="c8"><span class="input-group-addon " style="display:none;"><i class="fa fa-calendar"></i></span>
</div>

same script im using for date too as above.

if i type something in address input it will display in span. same i want in date

1

3 Answers 3

0

Try change event like this

   $('input').change(function(e){
           // set value in other input 
    });
Sign up to request clarification or add additional context in comments.

Comments

0
<div class="control-group">                 
<label class="control-label">Date:</label>
<div class="controls input-group date">
    <input type="text" class="span2 insert angular_input" id="c8">
      <span class="input-group-addon " id = "rc8" style="display:none;">
        <i class="fa fa-calendar"></i>
      </span>
</div>

<script>
   var inputField = document.querySelector("#c8");
   inputField.addEventListener("input",function(){
     var span = document.querySelector("#rc8");
     span.style.display = "block";
     span.textContent = inputField.value;
   })
</script>

Comments

0

Try change event like this

$('input').change(function(e){
    $("span").text(e.target.value);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.