Reputation: 127
how to check input text before POST operation? it must be numbers only
<form method="post" action="credit.php">
Сумма кредита: <input type="text" name="sum"> <br />
первый взнос: <input type="text" name="pv"> <br />
Срок: <input type="text" name="srok"> <br />
Процентная ставка: <input type="text" name="percent"> <br />
<input type="submit">
</form>
sorry for my bad english.
Upvotes: 1
Views: 352
Reputation: 15357
Use some kind of javascript..
<form method="post" action="credit.php" onsubmit="validateForm()">
<input type="text" name="pv" id="pv"> <br />
....
</form>
<script type="text/javascript">
function validateForm() {
var result = /^\d+$/.test(document.getElementById('pv').value);
return result
}
</script>
If your onsubmit returns false, the form won't go. If it returns true, the form will submit.
Upvotes: 4