Entry
How to check a value from the form, to contain only digits, size from 13 to 20 characters?
Jul 16th, 2001 11:26
Rich Cavanaugh, Sheni R. Meledath, Onno Benschop,
<?php
// get the length of the form field
$fieldlen = strlen($HTTP_POST_VARS['formfield']);
// check if it's greater than or equal to 13,
// less than or equal to 20,
// and that it is a number
if ( (($fieldlen >= 13) && ($fieldlen <= 20)) && (is_numeric
($HTTP_POST_VARS['formfield'])) ) {
// do stuff here if the field checks out
echo "OK";
} else {
// give an error here if it doesn't
echo "NOT OK";
}
?>