1 (edited by webgurl 2005-06-20 18:45)

Topic: Undefined message with custom field - RESOLVED

I've added custom fields to the registration page, and it works fine except for this annoying error... if the user doesn't enter a value for the custom field (which is required) the javascript message that pops up says

"undefined" is a required field in this form

The cursor does jump to this field when you press 'ok'

Could someone point out what I've missed here?

Here's some of the code in my custom register page:

inside the form

<!-- CUSTOM FIELDS FOR YEC -->
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_prof_reg['YEC Verify Legend'] ?></legend>
                    <div class="infldset">
                    <label><strong><?php echo $lang_common['Province'] ?></strong><br />
                        <input type="text" name="req_prov" size="50" maxlength="50" /><br /></label>
                    <label><strong><?php echo $lang_common['Age'] ?></strong><br />
                        <input type="text" name="req_age" size="4" maxlength="2" /><br /></label>
                    </div>
                </fieldset>
            </div>
            <!-- END CUSTOM FIELDS FOR YEC -->

checking post vars:

    //YEC CUSTOM FIELDS
    $yec_prov = pun_trim($_POST['req_prov']);
    $yec_age = pun_trim($_POST['req_age']);
    
    $username = pun_trim($_POST['req_username']);

..... buncha code here....

        // Validate username and passwords
    //and custom YEC fields
    if(strlen($yec_prov) < 2) {
        message($lang_prof_reg['Require Province']);
    }
    else if(empty($yec_age)) {
        message($lang_prof_reg['Require Age']);
    }
    else if (strlen($username) < 2)
        message($lang_prof_reg['Username too short']);
    else if (pun_strlen($username) > 25)    // This usually doesn't happen since the form element only accepts 25 characters...

Thanks

Re: Undefined message with custom field - RESOLVED

Should it say req_prov and req_age instead of yec_prov and yec_age?

Re: Undefined message with custom field - RESOLVED

Thanks scottywz, but that's not it either. I forgot to include this bit of code in my original post:

//YEC CUSTOM FIELDS
$yec_prov = pun_trim($_POST['req_prov']);
$yec_age = pun_trim($_POST['req_age']);

but just now added it to the above code.

Re: Undefined message with custom field - RESOLVED

What field does it jump to when you press OK?

Re: Undefined message with custom field - RESOLVED

you need to add to
$required_fields = array('req_username' => $lang_common['Username'], 'req_password1' => $lang_common['Password'], 'req_password2' => $lang_prof_reg['Confirm pass'], 'req_email1' => $lang_common['E-mail'], 'req_email2' => $lang_common['E-mail'].' 2');

line 244 register.php

Re: Undefined message with custom field - RESOLVED

Thanks Connorhd! That was it.