2017-01-03 1 views
-1

텍스트 필드가 비어 있고 경고 메시지가 나타나면 jQuery 유효성 검사 양식을 만들어야합니다. 난 당신이 체크 박스를 클릭 할 때 텍스트 상자를 확인하고 싶어 생각jQuery를 사용하여 검증 양식을 작성하는 방법은 무엇입니까?

<form action="" method="POST"> 
    <input type="checkbox" name="dropshiper_ceck" id="id_dropshiper_ceck"> 
    <label><b><?php echo $text_dropship; ?></b></label> 
    <div class="" id="id_dropshiper_form" name="dropshiper_form"> 
     <hr/> 
     <p> 
      <?php echo $text_dropship_name; ?> 
     </p> 
     <input type="text" name="nama_dropshiper" style="width: 97%" placeholder="<?php echo $text_add_name_dropshiper; ?>" id="id_nama_dropshiper" value=""> 
     <br/> 
     <br/> 
     <p> 
      <?php echo $text_dropship_telp; ?> 
     </p> 
     <input type="text" name="nomor_telp" style="width: 97%" placeholder="<?php echo $text_add_number_phone_dropshiper; ?>" id="id_nomor_telepon_dropshiper" value=""> 
    </div> 
</form> 
+0

이 참조 - http://stackoverflow.com/questions/12437339/how-to-check-if-the-any-of-my-textbox-is-empty-or-not-in-javascript –

+0

가능한 중복 [jQuery를 사용하여 입력이 비어 있는지 확인] (http://stackoverflow.com/questions/1854556/check-if-inputs-are-empty-using-jquery) – Darshak

답변

0
$('#id_dropshiper_ceck').change(function(){ 

    // Check the textbox when the checkbox is checked 
    if ($('#id_dropshiper_ceck').prop('checked') == true){ 
     if ($('#id_nama_dropshiper').val() == ""){ 
      // alert message 
     alert('Warning Message'); 
     } 
     if ($('#id_nomor_telepon_dropshiper').val() == ""){ 
      // alert message 
     alert('Warning Message'); 
     } 
    } 
}) 

:

이 내 코드입니다.

관련 문제