Hi,
When I input english letters and pressed submit button below, it returned false if I entered non-numerical value in price text box.
<input type="submit" name="submit" id="submit" value=" Submit " onClick="checkprice();">
javascript:checkprice(){
var fi = document.pxform;
if(fi.price.value==""||isNaN(fi.price.value))
{
window.alert('Please input number');
fi.price.focus();
return false;
}
}
However, I have an insert query to mysql DB and the price field is bigint.
if(isset($_POST['submit'])){
$price = trim($_POST['price']);
if($price != null) {
$query = "INSERT INTO transaction (price) VALUES (''$price');";
mysql_query($query) or die('Error, query failed. ' . mysql_error());
}
It has a SQL error as the input is english letters.
Although the js isNaN() works, it continously runs the query php code to try to insert a non numerical value to it.
How can I fix it?