javascript - Yii2 compare validation not working - Stack Overflow

admin2025-04-19  0

My problem is pare validation is not working correctly. If my min_bid_amount = 100 and min_buy_amount=1000, it's working. But problem occurs when min_bid_amount = 500 and min_buy_amount=1000. It also gives me error message.

Here is my model rule

public function rules()
{
    return [
        [['min_bid_amount','min_buy_amount'], 'number'],
        ['min_buy_amount', 'pare','pareAttribute'=>'min_bid_amount','operator'=>'>',
        'message'=>'Buying amount should be bigger than bid amount'],
        [['auction_start_date', 'auction_end_date', 'created'], 'safe'],
        [['id_product','min_bid_amount','min_buy_amount'], 'required']
    ];
}

Any help would be very much appreciated. I think JS does not convert it into int type value. So how could I do that?

My problem is pare validation is not working correctly. If my min_bid_amount = 100 and min_buy_amount=1000, it's working. But problem occurs when min_bid_amount = 500 and min_buy_amount=1000. It also gives me error message.

Here is my model rule

public function rules()
{
    return [
        [['min_bid_amount','min_buy_amount'], 'number'],
        ['min_buy_amount', 'pare','pareAttribute'=>'min_bid_amount','operator'=>'>',
        'message'=>'Buying amount should be bigger than bid amount'],
        [['auction_start_date', 'auction_end_date', 'created'], 'safe'],
        [['id_product','min_bid_amount','min_buy_amount'], 'required']
    ];
}

Any help would be very much appreciated. I think JS does not convert it into int type value. So how could I do that?

Share Improve this question edited Jan 22, 2016 at 21:49 Termininja 7,05612 gold badges50 silver badges50 bronze badges asked Dec 23, 2015 at 11:44 uiTeam324uiTeam324 1,25515 silver badges34 bronze badges 3
  • 1 Please, provide the error message – MurDaD Commented Dec 23, 2015 at 11:45
  • 1 "Buying amount should be bigger than bid amount" this is the error as per validation rule – uiTeam324 Commented Dec 23, 2015 at 11:50
  • 1 when min_bid_amount = 500 and min_buy_amount=1000. This also display error message 'Buying amount should be bigger than bid amount' ?? – Nana Partykar Commented Dec 23, 2015 at 12:04
Add a ment  | 

1 Answer 1

Reset to default 8

You should change the type of validation to number:

    ['min_buy_amount', 'pare','pareAttribute'=>'min_bid_amount','operator'=>'>',
    'message'=>'Buying amount should be bigger than bid amount', 'type' => 'number'],
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745021737a280422.html

最新回复(0)