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.
http://us.php.net/manual/en/function.base64-encode.php
http://pureform.wordpress.com/2008/03/23/make-your-website-completely-utf-8-friendly/

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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