All, I have a form on which the user is supposed to select a variable type (boolean, integer, real, date/time, text) from a select box and enter the default value for this selected variable type in a text box. I'm trying to validate that the default value entered matches the variable type selected i.e. user selects boolean so valid defaults could only be 0, 1, true, false and anything else would generate an error, or the user selects integer and enters 1.7 for the default would also throw a flag. I know that all of the form values submitted from the web page are strings but is there a way to test/convert the strings against the other variable types.
I'm sure that I'm not explaining this very well, but for example, if I use the following code I will always get an error displayed even if the user enters a valid value such as 3 in the default field because the form values are always submitted as strings. if ( ($GLOBALS['PageOptions']['Type'] == 'Integer') and (! is_int($GLOBALS['PageOptions']['Default']) ) ) { // display an error } If I use (int) on the form default value then that won't work either because if the default field value entered was not an integer but text such as 'snafu' then the value is always converted to an integer regardless. if ( ($GLOBALS['PageOptions']['Type'] == 'Integer') and (! is_int((int) $GLOBALS['PageOptions']['Default']) ) ) { // display an error } Thanks in advance, Dave Merritt [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php