Testcase X-Browser Textarea behavior

Javascript (Client) only.

The HTML spec is not very clear on how to interpret the newline after the opening textarea tag. Common sense seems to be to ignore a trailing newline after <textarea>.

In the form below you can test how your browser behave in two different cases: with and without trailing newline (\r\n) after the opening textarea tag. If you get the message "The fields differ!" when initially loading this page or have manipulated the textfields in the same way and pressed "Compare" something is wrong.

So what's the problem?

When filling the field nothing bad will happen since the browser knows what the user had already entered. But if the field is populated again it makes a difference. Almost all browser vendors seem to follow case 2 - ignoring the first newline after <textarea>.

Form 1 with \r\n after the opening tag:

        <textarea name="test">
        abc
        </textarea>
    

Form 2 without \r\n after the opening tag:

        <textarea name="test">abc</textarea>
    

Kommentieren