c# - Text from one textbox to another using JavaScript -


i have textbox as

 @html.textboxfor(m => m.singleunitbarcode, new { @class = "form-control",@id="barcode1", onblur = "clonedata" }) 

and on losing focus textbox want text in displayed in textbox(with id =customerbarcode_field)

i using javascript

<script>     function clonedata() {          var value = document.getelementbyid("#barcode1").value          document.getelementbyid("#customerbarcode_field").value = value;     } </script> 

however function not being triggered when lose focus first textbox.

what did miss ?

modify textbox this:

@html.textboxfor(m => m.singleunitbarcode,                  new { @class = "form-control",                       @id="barcode1",                        onblur = "clonedata()" }) 

and script this, in javascript mixing javascript jquery:

<script>     function clonedata() {          var value = document.getelementbyid("barcode1").value          document.getelementbyid("customerbarcode_field").value = value;     } </script> 

if want jquery then:

<script>         function clonedata() {              var value = $("#barcode1").val();              $("#customerbarcode_field").val(value);         }     </script> 

Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -