I have a problem, I have a function that makes a debit in the database, but if the User changes the amount by placing arithmetic operators the value becomes negative, thus crediting credits to the user instead of discounting.
How can I validate not to allow the input of +/- and also validate the value of the variable in the same way.
My debit function
function debitashop(valor){
getCreditosPlayer(function(output) {
var creditosplayer = output;
creditosplayer = parseFloat(creditosplayer);
valor = valor.val(valor.replace(/[^\w]/gi, ''));
valor = parseFloat(valor);
valor = (creditosplayer - valor);
$.ajax({
url: "ajax/debita.php",
type: "POST",
data: "creditos="+valor,
success: function(dados){
getCreditosPlayer(function(output) {});
}
})
});
}