I'm using a php snippet to validate a phone number contains x amount of digits in my webform. What I want to do for another text field is check that the first character of the textfield equals the letter "f". What is the code for that?

This is what I'm using for the phone number validation:

$telephone = $form_values['submitted_tree']['telephone'];
if(!ereg("^[0-9]{1,3}-[0-9]{3}-[0-9]{3,4}$", $telephone))
form_set_error('submitted][telephone', t('Phone number must be in format xxx-xxx-nnnn.'));

Comments

pbarnett’s picture

if (substr($stringname, 0 ,1) === 'f') ...

Pete