<input type="number" class="addme" value="'.$_REQUEST['pbill'].'" name="amount" min="0" required="required" placeholder="Enter amount of Pending Bills" title="Enter amount of Pending Bills" pattern="[0-9]{1,}" />
How do I ensure that the value to be input in the above will be a negative value?
after wide consultations i have come to the conclusion that this is the most viable answer...thanks to all that helped in the query $_REQUEST['amount'] = -$_REQUEST['amount'];
There is nothing sure about using pattern. You should check it out server side. But if You would like to use pattern to check this out, the pattern should be \-[0-9]+
As for PHP:
You simply check the value before inserting it to database:
if($_REQUEST['amount'] >= 0){ // $_REQUEST is generally for $_GET and $_POST
echo "Incorrect amount given. Please try again.";
die();
}
check the posted value, like
$amount = $_POST['amount'];
if($amount > 0) {
//echo 'positive';
$req_amt = (0 - $amount);
} else {
echo 'negative or 0';
}