Gowri
Gowri

Reputation: 16835

Validate password fields while current password field has value in magento

I'm having change password form in magento Account Information page.Here I want to validate password fields(password,confirm password,current password) while current password has value.Otherwise it should not validate.

In magento 1.5.1.0 really easy field validation is used to validate the forms.

I know addClassName add the validate like below

    $('current_password').addClassName('required-entry');
    $('password').addClassName('required-entry');
    $('confirmation').addClassName('required-entry');

removeClassName this one removes validation

$('current_password').removeClassName('required-entry');
$('password').removeClassName('required-entry');
$('confirmation').removeClassName('required-entry');

But how can i apply only while current_password has value.I'm not familiar with prototype.js functions .Kindly help me

Upvotes: 0

Views: 2732

Answers (1)

Max
Max

Reputation: 8836

In that template file, you can put a check in PHP around the javascript to add or remove validation. For example,

<?php if ($customer->getCurrentPassword()): ?>
    $('something').doStuff(); //however you want the logic to work
<?php endif; ?>

Upvotes: 1

Related Questions