masterofwee Posted September 21, 2008 Share Posted September 21, 2008 I'm writing a calculator to solve this formula, and I need a way to restrict all the textboxes on my form to only accept numbers. How can I do this with php? Link to comment https://forums.phpfreaks.com/topic/125215-how-to-restrict-a-text-box-to-nly-accepting-numbers/ Share on other sites More sharing options...
DarkWater Posted September 21, 2008 Share Posted September 21, 2008 <?php $input = $_POST['field']; if (!ctype_digit($input)) { echo "Input must only be a digit!"; } ?> Now, just letting you know, you wouldn't really use it like that. You'd implement it in a larger scheme, but this was just an example. Link to comment https://forums.phpfreaks.com/topic/125215-how-to-restrict-a-text-box-to-nly-accepting-numbers/#findComment-647225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.