Register Rule Javascript error
| From: | Doug Dalton | Date: | Fri, 01 Oct 2004 19:07:54 +0000 |
| Subject: | Register Rule Javascript error | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-14718@lists.php.net to get a copy of this message | ||
If I have a function:
function cmpPass($element, $confirm)
{
global $form;
$password = $form->getElementValue('newPassword');
return $password == $confirm;
}
and the form:
$form->registerRule('compare', 'function', 'cmpPass');
$form->addElement('password', 'newPassword', 'New Password: ','size=30');
$form->addRule('newPassword', 'Please provide a password','required'); $form->addRule('newPassword',
'Password cannot be more than 12 chars',
'maxlength', 5);
$form->addRule('newPassword',
'Password can only contain letters and ' .
'numbers', 'alphanumeric');
$form->addElement('password', 'confirm', 'Confirm Password: ','size=30');
$form->addRule('confirm', 'Please provide a password','required');
$form->addRule('confirm', 'Passwords dont match','compare');
$form->addElement('image', 'submit', $imgpath."images/update_profile_blue.gif");
I get the following javascript error:
Error: cmpPass is not defined
Source File:
<script type="text/javascript">
//<![CDATA[
function validate_bsprofile(frm) {
var value = '';
var errFlag = new Array();
_qfMsg = '';
value = frm.elements['confirm'].value;
if (value != '' && !cmpPass('', value, '') && !errFlag['confirm']) {
errFlag['confirm'] = true;
_qfMsg = _qfMsg + '\n - Passwords dont match';
}
if (_qfMsg != '') {
_qfMsg = 'Invalid information entered.' + _qfMsg;
_qfMsg = _qfMsg + '\nPlease correct these fields.';
alert(_qfMsg);
return false;
}
return true;
}
//]]>
</script>
What am I doing incorrecty or is this a quickforms error?