Stefano
Stefano

Reputation: 25

html textarea using specific character set

I would like to "force" a specific character set (ISO-8859-1) for a specific textarea html tag in a page.

I'm not sure if this is feasible either in HTML or using a JS technique, but to give an idea of what I would like to achieve:

<textarea character-set="ISO-8859-1"></textarea>

The above should allow the user to enter characters that are part only of the ISO-8859-1 character set, characters like € (EUR) should be blocked/displayed as dummy character.

I'm asking this since my website is integrated with a third-party service that only supports ISO-8859-1 characters and I want the user entering the message immediately see that some characters are not permitted.

Hope this make sense, thank you

Upvotes: 1

Views: 5252

Answers (1)

Mike Horstmann
Mike Horstmann

Reputation: 588

If you're looking to only accept a given charset from within a form, this link to W3Schools forms with "accept-charset=yourTargetCharSet" shows how to force the form to only accept certain charsets. (http://www.w3schools.com/tags/att_form_accept_charset.asp)

Alternatively, you could capture and convert any inputted text as required using the following ISO conversion references (http://www.w3schools.com/charsets/ref_html_8859.asp)

//In this scenario you would want to ID your textarea and gather the
//inputted values something like the following

<textarea id="getMeName"></textarea>
<textarea id="getMeOther"></textarea>

<script>
var thisFormNameData = document.getElementById("getMyName") 
//or the other id, and then you could manipulate that variable as
//needed to better suit your ISO within a UTF-8 doc
</script>

Upvotes: 1

Related Questions