更改错误消息以进行验证

时间:2016-03-30 11:23:10

标签: javascript magento

我正在使用以下link来显示验证错误消息。

因为我正在使用它:验证长度我收到错误消息:

Text length does not satisfy specified text range,但我想将此消息更改为:

Zip code is not servicable

<input placeholder="Enter your PIN Code" class="input-text 
   <?php if ($this->isFieldRequired('postcode')):?>
      required-entry
   <?php endif;?> 

   validate-length maximum-length-6 minimum-length-6 validate-digits"
   type="text"
   id="estimate_postcode"
   name="estimate[postcode]" 
   value="<?php echo $this->htmlEscape($this->getFieldValue('postcode')) ?>" 
   onkeydown="if (event.keyCode == 13) { return false;}"
/>

1 个答案:

答案 0 :(得分:1)

制作自己的javascript文件:

例如override.js并将其放在项目的js文件夹中。

然后在override.js文件中编写此代码:

Validation.add('validate-length', 'Zip code is not servicable')

在布局文件中,您需要使用addJs方法添加该js文件:

<action method="addJs"><script>override.js</script></action>