title: mvc3 checkbox checked or unchecked value using jquery
body: <p>I have a registration form which has some fields.. say i have 4 textboxes t1,t2,t3,t4</p>
  
  <p>While filling the registration for, when the user fills t1 and t2 and if he checks the checkbox then the data in t1 and t2 should be submitted in t3 and t4 respectively..</p>
  
  <p>if the user unchecks the checkbox then the data in t3 and t4 should be erased, actually i did this but im not sure if this the right way of doing it or not</p>
  
  <p>in my model i created a property for checkbox</p>
  
  <pre><code>  public bool ChkBox{get;set;}
  </code></pre>
  
  <p>my view</p>
  
  <pre><code>@Html.CheckBoxFor(m =&gt; m.ChkBox, new  { id = "c1" })
  </code></pre>
  
  <p>jquery code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  
  $('#c1').click(function () {
  
      var chk = $('#c1').is(':checked');
      if (chk == true) {
          var x = $('#t1').val();
          var y = $("#t2").val();
  
          $("#t3").val(x);
          $("#t4").val(y);
      }
      else {
          if (chk == false) {
              $("#t3").val('');
              $("#t4").val('');
  
          }
      }
  
  });
    &lt;/script&gt;
  </code></pre>
  
  <p>t1,t2,t3,t4 are the id's of my textboxes,
  currently this is working fine but is this the right way, or can i improve the code in any way?</p>