title: HTML flask To accept only integer input
body: <p>I'm trying to accept only integer input using the int() function and the type to number with min set. But I noticed that when I give an input like 5.0 it should treat it as an invalid input and accept only integers.</p>
  <pre><code>&lt;input autocomplete=&quot;off&quot; class=&quot;form-control&quot; min=&quot;0&quot; name=&quot;shares&quot; id=&quot;shares&quot; placeholder=&quot;Shares&quot; type=&quot;number&quot;&gt;
  
  def sell():
      &quot;&quot;&quot;Sell shares of stock&quot;&quot;&quot;
      rows = db.execute(&quot;SELECT * FROM tracker WHERE id=:id&quot;, id = session[&quot;user_id&quot;])
      if request.method == &quot;GET&quot;:
          return render_template(&quot;sell.html&quot;, rows = rows)
      else:
          symbol = request.form.get(&quot;symbol&quot;)
          shares = request.form.get(&quot;shares&quot;)
          if not shares:
              return apology(&quot;missing shares&quot;,400)
          if not symbol:
              return apology(&quot;missing symbol&quot;,400)
          lis = db.execute(&quot;SELECT * FROM  tracker WHERE id=:id AND name=:name&quot;, id=session[&quot;user_id&quot;], name=symbol)
          share = int(shares)
          if lis[0][&quot;no&quot;] &lt; share:
              return apology(&quot;too many shares&quot;,400)
          price = lookup(symbol)[&quot;price&quot;]
          cost = price * share;
          saving = db.execute(&quot;SELECT cash FROM users WHERE id=:id&quot;, id=session[&quot;user_id&quot;])[0][&quot;cash&quot;]
          db.execute(&quot;UPDATE users SET cash=:cash WHERE id=:id&quot;, cash=cost + saving, id=session[&quot;user_id&quot;])
          if lis[0][&quot;no&quot;] == share:
              db.execute(&quot;DELETE FROM tracker WHERE id=:id AND name=:name&quot;, id=session[&quot;user_id&quot;], name=symbol)
          else:
              db.execute(&quot;UPDATE tracker SET no=:no where id=:id AND name=:name&quot;,no=lis[0][&quot;no&quot;] - share,id=session[&quot;user_id&quot;], name=symbol)
          db.execute(&quot;UPDATE users SET cash=:cash WHERE id=:id&quot;, cash=saving+cost, id=session[&quot;user_id&quot;])
          flash(&quot;Sold!&quot;)
          return redirect(&quot;/&quot;)
  </code></pre>