自定义magento中的validate.js的验证错误消息 [英] Customize the validation error messages of validation.js in magento
问题描述
在我的magento应用程序中,结帐页面,将使用validation.js文件显示错误消息.
In my magento application the checkout page , will displays error message using validation.js file.
当我单击以继续输入新的帐单地址而不输入任何值时,它将显示错误消息为This is required field
.
when i click to continue in the new billing address without entereing some value it displays error message as This is required field
..
我想将此消息更改为其相应的字段名称.
I want to change this message as its corresponding field name .
我需要显示为First name is a required field
而不是该错误消息.
Instead of that error message i need to display as First name is a required field
..
我该怎么做?
编辑
这是输入框,位于customer/widget/name.phtml中,为:
this is the input box which is located in customer/widget/name.phtml as:
<input type="text" id="<?php echo $this->getFieldId('firstname')?>" name="<?php echo $this->getFieldName('firstname')?>" value="<?php echo $this->escapeHtml($this->getObject()->getFirstname()) ?>" title="<?php echo $this->getStoreLabel('firstname') ?>" maxlength="255" class="input-text validate-firstname" <?php echo $this->getFieldParams() ?> />
这是输出.
推荐答案
您可以在validation.js文件中创建另一个类,例如validate-firstname
并在您的validate.js文件中添加类似的内容
You can create another class in your validation.js file something like validate-firstname
and add something like this in your validation.js file
['validate-firstname', 'First name is required field.', function(v) {
return !Validation.get('IsEmpty').test(v);
}],
搜索此validate-alpha
验证行,然后将此代码放入js文件,然后在您的名字输入字段中添加validate-firstname
类.
Search for this validate-alpha
validation line and after put this code in your js file and add validate-firstname
class in your firstname input field.
这篇关于自定义magento中的validate.js的验证错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!