I have the following input that requires validation. When the remote method is failed, it displays an error message Please fix this field.. How can I customize this message?

<input type="text" data-validate="{required:true, email:true, remote:'/bonus-point/transfer/validateRecipientEmail'}" class="input-text" title="Recipient Email" value="" id="recipient_email" name="recipient_email" aria-required="true">

1 Answer 1


There is a way to return a custom error message in json

public function execute() {
    $resultJson = $this->resultJsonFactory->create();
    $message = $this->getRequest()->getParam('message');
    if (strlen($message) < 3) { 
        $resultJson->setData('Message too short'); // error
    } else {
        $resultJson->setData('true'); // success
    return $resultJson;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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