2016-07-11 7 views
-1

こんにちは、みんな、cshtmlのテキストボックスの色を変更するには?私はこのコードを持っています条件付きのhtmlテキストボックスに色を入れる方法は?

$("#BUTTON").click(function (event) { 
    var urlPA = URL; 
    var crty = $("#Courtesy").val(); 
    var fname = $("#Familyname").val(); 
    var gname = $("#GivenName").val(); 

    if (crty != 0 && fname != 0 && gname != 0) { 
     $.ajax({ 
      type: "GET", 
      url: urlPA, 

      data: 'DATA', 
      success: function (response) { 
       alert(response); 
      /// when success the color of the textbox return to normal 
      }, 
      datatype: "text" 
     }); 
    } else { alert("Please fill up the required fields."); 
    ////// when error the textbox background makes red 

} 
}); 

どのようにすればいいですか?。ありがとう。

+0

を。私は、テキストボックスが色を変えるかどうかの条件を持っています。コード例を参照してください。 – UkI

答えて

0

あなたは、インラインスタイルを設定するためにjQueryのcss機能を使用することができます。@GiladGreenその異なる

if (crty != 0 && fname != 0 && gname != 0) { 
    $.ajax({ 
     type: "GET", 
     url: urlPA, 

     data: 'DATA', 
     success: function (response) { 
      alert(response); 
      /// when success the color of the textbox return to normal 
      $('#Courtesy').css('background-color', 'white'); 
      // add other fields 
     }, 
     datatype: "text" 
    }); 
} else { alert("Please fill up the required fields."); 
    ////// when error the textbox background makes red 
    $('#Courtesy').css('background-color', 'red'); 
    // add other fields 
} 
+1

は機能しません。 :( – UkI

+0

ありがとうございました。私は間違いを解消しました。 – UkI

関連する問題