Aditya
Aditya

Reputation: 1104

Laravel 6 - How to make user cannot use tomorrow and later date

I want to make user wouldn't be able to pick date after today, so they will only be able to input today's date or before that.

This is my calendar code I'm using carbon

<div class="form-group">
    {{ Form::label('transaction_in_date', 'Transaction Date') }} <br>
    {{ Form::date('transaction_in_date', \Carbon\Carbon::now()->format('d M Y')) }}
</div>

Is there any way to achieve that?

Upvotes: 0

Views: 257

Answers (1)

nakov
nakov

Reputation: 14288

You can use the before or equal validation rule:

'transaction_in_date' => 'before_or_equal:today'

Upvotes: 1

Related Questions