Detecting CRLF with Javascript

Kmcnet 946 Reputation points
2025-02-06T20:32:23.3366667+00:00

Hello everyone and thanks for the help in advance. I am working with an Asp.Net Core page that accepts the data into a <textarea> from a QR code scanner. When the scanner sends the data to the page, there is clearly some time of hidden line break after the input. I then tried redirecting the scanned input to Notepad++ and the end of the line shows CR|LF. I tried

        if ($("#txtqrcodescan").val().indexOf("/\r\n") !== -1) {
            alert("CR/LF detected");
        }

But this doesn't work. I also tried it without the escape character without success. Any help would be appreciated.

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,038 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.