【发布时间】: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>
【问题讨论】:
-
该字段已由
<?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>验证,在输入的class=""中定义。客户将无法输入电话号码以外的任何内容。 -
感谢 axel 的回复
标签: javascript forms magento contact