2

I used Magento phone number validation validate-length maximum-length-11 minimum-length-11 validate-digits for phone number

is any other way to restrict phone number?

0

try this

<input type="text" name="billing[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?> validate-mobileno" id="billing:telephone" placeholder="Mobile"/>

<script type="text/javascript">
//<![CDATA[
if(Validation) {
Validation.addAllThese([
['validate-mobileno','Enter correct mobile number (Eg:919986858483)',
function(v){
var timePat ="^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}9[0-9](\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$";
// var matchArray = v.match(timePat);
if(v.length > 0){
if(v.length !=12){
    return false;
   }else if(v[0] != 9 || v[1] != 1 ){

    return false;
   }else if(v[2]!=9 && v[2]!=8 && v[2]!=7){

    return false;
   }


return true;

}else {
return false;
}

}
]])};
 var dataForm = new VarienForm('form-validate', true);
//]]>
</script>
| improve this answer | |
  • ok i will try this – user31402 Oct 3 '15 at 16:35
  • ya it's working perfectly what i want thanks lot – user31402 Oct 3 '15 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy