Stop UTF 8 with javascript

Below is how you can detect non-ascii characters with javascript.

s = $("#something").val();
for (var i=0; n = 128) {
		alert('Invalid character '' + String.fromCharCode(c) + ''');
		return false;  // or throw an error

Of course if you have to take in non-ascii values, then be prepared to set up your environments first. The links below will help.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s