1

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">
0

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, privacy policy and cookie policy

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