0

このコードを使用して、ドロップダウンで値が選択されているかどうかを確認しています。

$(document).ready(function () {
$("send").click(function () {

if (document.getElementById('dropdown1').selectedIndex == 0)
$("#msg_dropdown1").html("Required");

});
$('#dropdown1').change(function(){$('#msg_dropdown1').hide()})
});

値が選択されるまで送信ボタンを無効にする方法はありますか?

<input type="submit" id="send" value="SEND" class="greyishBtn" />
4

4 に答える 4

0

まず、IDセレクターを使用しますsend

交換する $("send").click(function () {

$("#send").click(function () {

    $('#dropdown1').change(function(){
        if($('#dropdown1').val() != 0){
            $("#send").attr("enabled","enabled");
        } else{
            $("#send").attr("disabled","disabled");
        }
    });
于 2013-03-21T04:24:44.853 に答える
0

$("send").click(function () { に 変更 $(#"send").click(function () {

于 2013-03-21T04:22:28.170 に答える
0
$(document).ready(function () {
    $("#send").click(function () {
        if (document.getElementById('dropdown1').selectedIndex == 0)
            $("#msg_dropdown1").html("Required");
    });
    $('#dropdown1').change(function(){
        if($(this).val() != 0){
            $("#send").removeAttr("disabled");
        }
        else{
            $("#send").attr("disabled","disabled");
        }
    });
});

<input type="submit" id="send" value="SEND" class="greyishBtn" disabled="disabled" />
于 2013-03-21T04:26:57.363 に答える
0

これを試して

   <select id="dropdown1" name="dropdown1" onchange="unblock(this)">

    function unblock(arg){
      if(arg.options[arg.selectedIndex].value !=0){
      $('#send').css('display','block');
      }
    }
于 2013-03-21T04:27:05.147 に答える