简体   繁体   中英

restrict the “textfield” to accept only digits and maximum 10 digits in magento form

here is a code : http://pastebin.com/qCNGSKRn to display telephone filed to enter telephone number.

i want to restrict above field to accept only numbers and also maximum 10 numbers to be entered. all special charactars and special symbols and white spaces should not allowed.

that field should not accept more than 10 digits.

please help me to find solution.

<div class="field">
                <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
                <div class="input-box">
                    <input type="text" name="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') ?>" id="telephone" />
                </div>
            </div>

i have to use this in class " class="input-text validate-length maximum-length-10 minimum-length-10 validate-digits helper('customer/address')->getAttributeValidationClass('telephone') ?>"" https://magento.stackexchange.com/questions/56413/restrict-the-textfield-to-accept-only-digits-and-maximum-10-digits-in-magento

http://inchoo.net/magento/out-of-the-box-form-validation-in-magento/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM