Here i am trying to do the validation for the html input form. here i want to return false if the input is not a number. i want to return false if anything else other than number is supplied as input.
How can i do this? what is the pattern for the number validation
<form class="form-horizontal" name="product-form" method="post" action="go.php" role="form" enctype="multipart/form-data" onsubmit="return validateForm();">
<div class="form-group">
<label class="control-label col-sm-2" for="product_price">Product Price</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="product_price" id="product_price" placeholder="36000" required>
</div>
</div>
</form>
Javascript
function validateForm() {
var x = document.forms["product-form"]["product_price"].value;
if (x == null || x == "") {
alert("price must have only numbers");
return false;
}
}