Make form allow minimum number 10 or higher to be inputted

Scorpion Ghost

Elite Member
Executive VIP
Jr. VIP
Joined
Mar 22, 2013
Messages
9,143
Reaction score
10,489
I have a form on my site, and I want to make the minimum number that's allowed to be inputted be 10 or higher.

Here's the code for that form:

PHP:
<input type="number" id="amount" onchange="updateInput(this.value)" class="form-control" value="10" placeholder="1.00" autocomplete="off" required>

Can anyone help me get this done?

Thank you
 
I have a form on my site, and I want to make the minimum number that's allowed to be inputted be 10 or higher.

Here's the code for that form:

PHP:
<input type="number" id="amount" onchange="updateInput(this.value)" class="form-control" value="10" placeholder="1.00" autocomplete="off" required>

Can anyone help me get this done?

Thank you

I suppose adding "min" attribute with value set to 10 should do the trick:

PHP:
<input type="number" id="amount" onchange="updateInput(this.value)" class="form-control"  min="10" value="10" placeholder="1.00" autocomplete="off" required>
 
br amar is right, but I'd like add that the min attribute is new in HTML5. So if you want browser cross-compatibility add in a JavaScript function to do a secondary check.

For Example: (i dont have nuff posts yet so copy and paste the following into your URL box.
jsfiddle.net/2dq06qpc/

Note: replace the 1 with 10 if you want the min number to be 10.
 
Back
Top