Jump to content

Getting errors whith numbers


monkeybidz

Recommended Posts

When I enter a value of less than 1.00 I get an alert. I want to be able to enter a numeric value of 0.01 and above. Here is the script:

 

 

<script type ="text/javascript">

function chkbidprice()

{

 

//alert(parseInt(document.getElementById('buy').value));

 

if(parseInt(document.bid.bid.value) >0){}

else

{

alert("Your maximum bid is invalid. Please bid again!");

return false;

}

if(parseInt(document.bid.bid.value) < parseInt(document.getElementById('start').value))

{

alert("Your maximum bid should be greater or equal to start bid! Please try again!");

return false;

}

if((parseInt(document.getElementById('buy').value)>0) && parseInt(document.bid.bid.value) > parseInt(document.getElementById('buy').value))

{

alert("Your maximum bid can not be greater than Buy it now ! Please try again!");

return false;

}

}

 

  </script>

 

Link to comment
https://forums.phpfreaks.com/topic/92394-getting-errors-whith-numbers/
Share on other sites

 

try this and see how it works out for you:

 


<script type="text/javascript">
                  function chkbidprice()
                  {
                     var currentBidVal = document.bid.bid.value;
                     var bidval = parseInt(currentBidVal);
                     var intial = document.getElementById('start').value;
                     var beginbid = parseInt(intial);
                     var buyItNow = document.getElementById('buy').value;
                     var buy = parseInt(buyItNow);

                     if (bidval > 0)
                     {
                     // do nothing
                     }
                     else if (bidval == "0")
                     {
                        alert("Your maximum bid is invalid. Please bid again!");
                     }
                     else if (bidval < beginbid)
                     {
                        alert("Your maximum bid should be greater or equal to start bid! Please try again!");
                     }
                     else if (buy > "0" && bidval > buy)
                     {
                        alert("Your maximum bid can not be greater than Buy it now ! Please try again!");
                     }
                  }
                  
                 </script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.