I'm using Webforms module and, in particular, a Date field. Using built-in validation and intentionally triggering the validation error, the message looks like follows:

The entered date must be 04/04/1914 or later.

Have no error here. What I need is to customize that error message (I need to show (1) a different message, and (2) in a different language).

Question: How can I alter the webform to override the message with my custom one?


Go ahead and download this https://drupal.org/node/1209450 module in zip. there are two zips you can download any one. here is the code can you use now

function modulename_message_alter(&$message) {

       foreach($message->messages['error'] as &$val) {
        if(preg_match('@The entered date must be \w+/\w+/\w+ or \w+.@',$val)){
            $val='This is not correct date';
  • It is not working: my hook (ensured replacing modulename with my actual module name) is never invoked. – Luis Masuelli Apr 4 '14 at 19:59
  • @LuisMasuelli did u clear cache? – Ali Nouman Apr 4 '14 at 20:00
  • yes, the first think I thought about, was in the treacherous cache. – Luis Masuelli Apr 4 '14 at 20:01
  • ok, dpm($message) and see do you get some thing? – Ali Nouman Apr 4 '14 at 20:07
  • I made it work. Don't know what happened ... just reinstalled/reactivated the module. – Luis Masuelli Apr 4 '14 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.