-1

i have add class "validate-phoneStrict" with phone number input but still i am able to add alphabets in phone number field. what i have to do to solve problem?

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

1 Answers1

0

You should have to wrote the java script function to do the phone number validation

<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>
Chirag Viradiya
  • 477
  • 4
  • 10