How to modify Javascript code to limit total value to 6?

Hello,

Currently, I am working to create a custom chocolate box on my Shopify site using line item properties. Thanks to the help of others, I have some good code that works perfectly for what I need. I just need one more thing for it to work perfectly.

Currently, I have a script that shows a warning div and deactivates the shop button when the “total” text box is fewer than 6. My question is, how would I format additional code to also deactivate the button and show the warning if the total value is greater than 6? Ideally, the only time the add to cart button would be active is if the total amount of chocolates is 6.

Hopefully, that makes sense. I would appreciate any help or guidance with this issue.

Here is a link to my preview store: https://ytdjuu2imo3hpkq8-55407378621.shopifypreview.com/products_preview?preview_key=ca1ca6fa3f711bb876ecfc1ac4915d46

Here is the code I am using for the product page:


  
  

  
 

  
  

  
  

  
  

  
  

  
  

  
  

  
  

   

_*Please Choose 6 Truffles_

   

  
  Total : 

In case anyone is having issues with this, I managed to find a solution. This probably isn’t the best approach, but it does work if anyone is trying to set up their own custom product using line item properties. I added a few lines and now, the plus button will be disabled when the total reaches 6. That way, customers can only select 6 truffles. Here is what I did:


  
  

  
 

  
  

  
  

  
  

  
  

  
  

  
  

  
  

   

_*Please Choose 6 Truffles_

   

Total :