-1

I need to create jQuery validation form if text field is empty then came the warning.

This is my code:

<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>
2

1 Answer 1

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');
        }
  }
})

I guess you wanna check the textbox when the checkbox is clicked.

Sign up to request clarification or add additional context in comments.

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.