限制" textfield"以magento形式仅接受数字和最多10位数

时间:2015-02-17 05:29:05

标签: javascript forms magento contact

这是一个代码:http://pastebin.com/qCNGSKRn,用于显示输入电话号码的电话。

我想限制上面的字段只接​​受数字,也要输入最多10个数字。不允许使用所有特殊字符和特殊符号和空格。

该字段不应超过10位数。

请帮我找到解决方案。

<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>

1 个答案:

答案 0 :(得分:0)

我必须在类“class =”中使用它输入文本validate-length maximum-length-10 minimum-length-10 validate-digits helper('customer / address') - &gt; getAttributeValidationClass('telephone') ?&gt;“”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/

相关问题