Javascript 如果输入的值小于最低投标金额,如何禁用按钮单击?

Javascript 如果输入的值小于最低投标金额,如何禁用按钮单击?,javascript,jquery,html,asp.net-mvc-4,Javascript,Jquery,Html,Asp.net Mvc 4,如果在下面名为“bidamt”的文本框中输入的值小于下表中的最小投标值,我希望能够禁用按钮单击。我该怎么做呢?我正试图用JavaScript实现这一点,但它似乎没有达到最低出价。任何帮助都将不胜感激 @model IList<NucorPrototypes_V1.ViewModel.AuctionPage> @{ ViewBag.Title = "MyBids"; } <!doctype html>

如果在下面名为“bidamt”的文本框中输入的值小于下表中的最小投标值,我希望能够禁用按钮单击。我该怎么做呢?我正试图用JavaScript实现这一点,但它似乎没有达到最低出价。任何帮助都将不胜感激

      @model IList<NucorPrototypes_V1.ViewModel.AuctionPage>

      @{
          ViewBag.Title = "MyBids";

       }

      <!doctype html>
       <html>
       <head>
<title>Auction </title>
<script type="text/javascript">

    function checkBids(el) {
        var bidInput = el.value
        var MinBid = confirmbids.MinBid.value
        if (el.value <= MinBid) {
            document.getElementById("Bid").disabled = true;
        }
        else {
            document.getElementById("Bid").disabled = false;
        }
    }


    function RemoveBid(rb) {
        if (typeof (rb) == "object") {
            $(rb).closest("tr").remove();
        }

    }


</script>
 @*<script type="text/javascript">

   $('#bidamt').bind('keyup', function () {
       if (Filled()) $('#btnSubmit').removeAttr('disabled');
   });

   function Filled() {
       var filled = true;
       $('body input').each(function () {
           if ($(this).val() == '0') filled = false;
       });
       return filled;
   }

       *@
      @*<script type="text/javascript">

       //Validates that textbox value entered is a number or a number with a decimal
       function checkDec(el) {
           var typedBid = el.value
           var min = confirmbids.MinBid.value

           if (el.value <= confirmbids.MinBid.value) {
               //alert("Invalid Bid Amount. Please enter a correct bid amount.");
               document.getElementByName("Bid").disabled = true;
           }
           else {
               document.getElementById("message").innerHTML = 'Your Bid is ' + el.value;
               document.getElementByName("Bid").disabled = false;
           }
       }
@model-IList
@{
ViewBag.Title=“MyBids”;
}
拍卖
功能检查码(el){
var bidInput=el.value
var MinBid=confirmbids.MinBid.value
if(el.价值项目高标)
@DisplayFor(modelItem=>item.Coil\u等级)
@DisplayFor(modelItem=>item.Coil\u HeatNo)
@DisplayFor(modelItem=>item.Coil\u Gauge)
@DisplayFor(modelItem=>item.Coil\u宽度)
@DisplayFor(modelItem=>item.Coil_-Weight,new{@id=“CoilWeight”})
@DisplayFor(modeleItem=>item.Coil\u Defect1)
@DisplayFor(modelItem=>item.Coil\2)
@DisplayFor(modelItem=>item.Coil\3)
}




`

使用jquery,您可以尝试以下方法: 要使用jquery,只需嵌入

<script src="http://code.jquery.com/jquery-1.10.2.js"></script> 
像这样:

$("#Bid").click(function(){
      if(something true){
       $(this).attr('disabled','disabled');
      }
    });

将bidamt文本框放入foreach循环中,并设置id=“bidamt”。所以问题是你不能设置相同的id很多元素,id是唯一的。第二个问题是在按钮的单击事件中调用了checkBids函数,因此无法获取按钮的值。

谢谢您的输入。我会把它放在JavaScript函数中吗?此外,是否需要通过单击按钮或按键来完成此操作?由于某种原因,它不想在我的功能最低出价拉。我需要它是if(bidamt)它不一定要禁用按钮。我只需要它不提交在输入字段中输入的实际金额,并给他们一个错误,让他们重新输入金额。
$("#Bid").attr('disabled','disabled');
$("#Bid").click(function(){
      if(something true){
       $(this).attr('disabled','disabled');
      }
    });