I’m trying to set a max attribute based on the retrieved value in my database but it doesn’t seem to work for me.
These is the codes that I tried
//
<input type="number" name="entered_qty" placeholder="Enter Quantity" min="1" max="<?=$data->store_quantity?>" required>
//
<input type="number" name="entered_qty" placeholder="Enter Quantity" min="1" max="{{$data->store_quantity}}" required>
I also tried to retrieve it as value="{{$data->store_quantity}}"
to see if I’m able to retrieve the value in my database and it does. Furthermore there data types in my database are int
but if I do it manually like this, it works just fine
<input type="number" name="entered_qty" placeholder="Enter Quantity" min="1" max="5" required>
this is also how I retrieve it in my database in my controller
public function products($encryption_id){
$encrypt_id = Crypt::decrypt($encryption_id);
$data=product::where('id',$encrypt_id)->first();
return view("admin.products",compact("data"));
}
What should I do?
2
Answers
You can validate the user using the dropdown as shown below.
{{$data->store_quantity}}
may not be an integer or number or may be smaller than 0.Try this: