【问题标题】:restrict the "textfield" to accept only digits and maximum 10 digits in magento form将“文本字段”限制为仅接受数字和最多 10 位 magento 形式的数字
【发布时间】:2015-02-17 05:29:05
【问题描述】:

这里有一个代码: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>

【问题讨论】:

  • 该字段已由&lt;?php echo $this-&gt;helper('customer/address')-&gt;getAttributeValidationClass('telephone') ?&gt; 验证,在输入的class="" 中定义。客户将无法输入电话号码以外的任何内容。
  • 感谢 axel 的回复

标签: javascript forms magento contact


【解决方案1】:

我必须在类“ 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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    • 2013-07-05
    • 2018-04-09
    • 1970-01-01
    • 2013-01-14
    相关资源
    最近更新 更多