简体   繁体   中英

Change the error message for validation

I am using following link for displaying validation error messages.

as I am using this : validate-length I am getting error message as :

Text length does not satisfy specified text range , but I want to change this message as:

" 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;}"
/>

Make your own javascript file:

For example override.js and put it in the js folder of your project.

Then write this code in that override.js file:

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

In the layout file you need to add that js file with the addJs method:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM