Changing the required error message – “This field is required”

To change the required message, pass in an additional parameter to the addValidator line, containing an array of options with your message, the syntax and array nesting is important. Copying the code here is a good idea, just be sure to change $element to match your element’s unique name.

1
2
3
$element->addValidator('required', array(
    'messages' => array('required' => 'This is a required field')
));
$element->addValidator('required', array(
    'messages' => array('required' => 'This is a required field')
));

NOTE: if you are having any problems with this, you can change the message directly in the file lib/Quform/Validator/Required.php near the top of the file. The same goes for the other validators.

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy