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

1 Answer 1

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 and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.