unable to submit form after a condition is true
Hi,
I have the following code, but I am able to prevent the form submit when the qty is less than the min bid amount but unable to submit the form when the qty is greater than min bid.
first time if input qty with a lesser value and then input the qty value greater than min_bid then the form is unable to submit.
If I input qty value greater than min_bid amount in the first time then I am able to submit the form
Please help
- <form class="form-inline" method="post" id="auctionform" action="<?php echo base_url(); ?>orders/create">
- <div class="form-group" id="bid_tab">
- <label class="fee_text" for="registration_fee">Registration fee</label>
- <label class="money_symbol " for="registration_fee">₹</label>
- <label class="fee" for="registration_fee"><?php echo $content->starting_bid; ?></label>
- <input type="hidden" name="amount" value="<?php echo $content->starting_bid; ?>" >
- <input type="hidden" name="exp_id" value="<?php echo $content->id; ?>" >
- <input type="hidden" name="exptype" value="<?php echo $content->exptype; ?>" >
- </div>
- <div class="form-group" id="bid_tab">
- <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
- <div class="input-group">
- <div class="input-group-addon">₹</div>
- <input type="text" class="form-control btn-block" id="qty" name="qty" placeholder="Amount">
- <div class="input-group-addon" style="padding-left: 35px; padding-right: 35px;">MINIMUM NEXT BID ₹ <?php echo $qty; ?></div>
- </div>
- </div>
- <br>
- <div class="col-md-12 form-group">
- <div class="checkbox">
- <label><br><br>
- <input id="agree" type="checkbox" checked> I Accept all terms and conditions
- </label>
- </div><br><br>
- <!-- <button type="submit" id="make_payment" class="btn btn-default btn-block">MAKE PAYMENT</button>-->
- <?php if(isset($_SESSION['user_type']) && ($_SESSION['user_type']=="client")){ ?>
- <button type="button" id="make_payment" class="btn btn-default btn-block">MAKE PAYMENTS</button>
- <?php }else{ ?>
- <a href="#" id="bid_btn" class="text-uppercase btn btn-default btn-block" data-toggle="modal" data-target="#myModal_login">Login to Buy </a>
- <?php } ?>
- </div>
-
-
- </form>
- <!-- JAVASCRIPT ------------->
- <script>
- $(document).ready(function(){
-
- $("#make_payment").on("click", function(event) {
-
- var qty=$("#qty").val();
- var min_bid=5200;
- alert("qty="+qty + " "+ "min bid="+ min_bid);
- if(qty > min_bid)
- {
- alert("bid amount is greater");
-
- $("#auctionform").submit();
-
- }
- else if(qty < min_bid){
- alert('Bid amount cannot be less than next bid amount');
- $("#auctionform").submit(function(event) {event.preventDefault();});
- }
-
- });
-
- });
- </script>
I am not sure where I am missing something.
Please help.