Coolcrab
Coolcrab

Reputation: 2723

HTML form gives odd artifact

I'm making a form and I keep getting an odd artifact next to the textbox. So right after the <br> and right before the <textarea the page loads ​.

What could be causing this?

    <input name="pasnr" type="text" value="<?=$pasnr ?>" size="79"><br>
    Commentaar: <br>
    ​<textarea name="comments" rows="10" cols="50"><?=$comments ?></textarea><br>
    <input type="submit" name="Submit" value="Change">

Upvotes: 1

Views: 247

Answers (2)

matt
matt

Reputation: 79723

This looks like an encoding issue.

The Unicode character ZERO WIDTH SPACE is at codepoint U+200B. When expressed in UTF-8 this character is represented by the three bytes E2 80 8B. If these bytes are then interpreted as characters in the CP-1252 encoding they appear as the characters ​.

From the position these characters appear on your page it looks like you’ve somehow introduced a zero width space character in your editor (which is using utf-8) and since you’re not specifying an encoding the browser is defaulting to CP-1252.

A simple fix in this case would be to specify the encoding of the page, either by setting a Content-type header, or by adding <meta charset='utf-8'> to your page (assuming you’re using HTML5). (Alternatively just find the character in the file and delete it).

More generally you need to make sure the encodings you use throughout your application are consistent (i.e. your pages, the database, data from form submissions). If you’re new to character encodings a good place to start is Joel Spolsky’s article.

Upvotes: 4

VitaliyG
VitaliyG

Reputation: 1857

Just viewed source of your page, there is simply some junk before textarea.

I bet this is UFT8 BOM(special 3char sequence at beginning of utf8 encoded file). If page source comes from text file check if there is UTF8 BOM at file beginning and save file without a BOM.

Upvotes: 1

Related Questions