Hi,
I have a form validation function which basically looks for two things:
1) if any of the fields is blank
2) if any firstname/lastname contains a space
in the form, there are 7 fields ... first name, last name, email address, password, address, city, country.
Now, even if i have some data in the form, upon submission, it gives me an error saying 3 of the 7 (password, address, city) are blank and the first two contain a space.
Any idea on why is this occuring ??
I am pasting the code .. i doubt there's anything wrong with the code but nevertheless .. if it helps ..
thanks a lot ...
<?php
function yes_alumni_info_sample_validate($form_id, $form_values){
foreach($form_values as $field=>$value) {
if($value != '') continue;
switch($field) {
case 'firstname':
case 'lastname':
case 'email':
case 'password':
case 'homeaddress':
case 'homecity':
case 'homecountry':
form_set_error($field,t('The value for '.$field.' cannot be blank.'));
break;
}
}
if (strlen(preg_replace('/\s+/', '', $form_values['firstname'])) != strlen($form_values['firstname'])){
form_set_error('firstname', t('Please remove spaces from your firstname'));
form_set_error('firstname','',true);
}
if (strlen(preg_replace('/\s+/', '', $form_values['lastname'])) != strlen($form_values['lastname'])){