Jump to content

how to restrict a text box to nly accepting numbers


masterofwee

Recommended Posts

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.