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