Table of Content

Custom form validation

<input class="input-text required-entry validate-phone" id="client-tel" type="text" name="client[tel]" value="" />
<script type="text/javascript">// <![CDATA[
Validation.add('validate-phone','<?php echo $this->__('Phone number must start from 0!') ?>', function(value){
    var phoneNumber = value.replace(/\D/g, "");
    if (phoneNumber.match(/^0\d{8,}$/)) {
        return true;
    }
    return false;
});
var anketaForm = new VarienForm('form_anketa', true);
// ]]></script>
Last modified: 20.01.2018

Author

Comments

Write a Reply or Comment

Your email address will not be published.