Share via

Detecting CRLF with Javascript

Kmcnet 1,376 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.

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments

Your answer

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