본문 바로가기
jQuery

TextBox

by 캡틴노랑이 2015. 9. 1.
반응형

텍스트 박스 잠금 및 텍스트 박스의 내용 키보드에 눌림과 동시에 복사
 <fieldset id="shippingInfo">
        <legend>sdfsdfsdf</legend>
        <label for="shipName">sdfsdfsdf</label>
        <input name="laa" id="shipName" type="text" />

        <label for="shipAddress">sdfsdfsdf</label>
        <input name="shipAddress" id="shipAddress" type="text"  />

       
    </fieldset>
    <fieldset id="billingInfo">
        <legend>sdfsdfsdf</legend>
        <label for="sameAsShipping">sdfsdfsdf</label>
        <input name="sameAsShipping" id="sameAsShipping" type="checkbox" value="laalaaa" />

        <label for="billName">sdfsdfsdf</label>
        <input name="billName" id="billName" type="text"  />

        <label for="billAddress">sdfsdfsdf</label>
        <input name="billAddress" id="billAddress" type="text"  />
    </fieldset>
 
    

     <script type="text/javascript">


         $("#sameAsShipping").change(function () {
             if (this.checked)
                 $("#billingInfo input:text").attr("disabled", "disabled").each(function (i) {
                     var valueFromShippingInput = $('#shippingInfo input:text:eq(' + i + ')').val();
                     $(this).val(valueFromShippingInput);
                 });
             else
                 $("#billingInfo input:text").removeAttr('disabled');

         }).trigger('change');

         $('#shippingInfo input:text').bind('keyup change', function () {
             if ($('#sameAsShipping:checked').length) {
                 var i = $('#shippingInfo input:text').index(this);
              
                 var valueFromShippingInput = $(this).val();
                 $('#billingInfo input:text:eq(' + i + ')').val(valueFromShippingInput);
             }

         });

 

readonly
 $("input[name=id]").attr("readonly",true); 

$("#p_des").attr("readonly", true); 
disabled
 $("input[name=sel]").attr("disabled",true);

 

반응형

'jQuery' 카테고리의 다른 글

특정 태그에 HTML 태그포함된 텍스트 넣기  (0) 2015.09.01
css관련 class 메서드 및 응용  (0) 2015.09.01
DROPDOWNLIST  (0) 2015.09.01
XML문서 읽어 오기  (0) 2015.09.01
ListBox  (0) 2015.09.01

댓글