js/prototype/validation.js
I have two classes: validate-email, validate-mobilePhoneNumber
customer/form/login.phtml
In email input, the customer can log with the email address or a phone number, so what I would like to do is that when the user enters an email address, I validate the email class: validate-email and if he enters a phone number I validate it the phone class: validate-mobilePhoneNumber
<li>
<label for="email" class="required"><em>*</em><?php echo $this->__('Email address or phone number') ?></label>
<div class="input-box">
<input type="text" name="login[username]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" id="email" class="input-text required-entry " title="<?php echo $this->__('Email address or phone number') ?>" />
</div>
</li>
EDIT: On the basis of the answer of Jaimin Sutariya
In js/prototype/validation.js we need to add a custom validation
Validation.add('validate-email-or-phone', 'Please enter a valid Email address or phone number.', function(v) {
return Validation.get('IsEmpty').test(v) || Validation.get('validate-email').test(v) || Validation.get('validate-mobilePhoneNumber').test(v)
})