Hi. I'm using the following function to check input on text fields for invalid characters (mostly foreign characters). It works if there is only invalid characters in the string, and it works if there are valid characters typed before the invalid characters, but doesn't work if there are valid characters typed before and after the invalid ones. Can someone tell me what i'm doing wrong? Thanks!

Code:
function chkchar2()
{

	for (var j=0;j < document.forms[0].length;j++) 
	{
		if (document.forms[0].elements[j].type == "text" || document.forms[0].elements[j].type == "textarea")
		{ 
			for (var i = 0; i < document.forms[0].elements[j].value.length; i++)
			{
				var myregexp = new RegExp("[A-Z]|[a-z]|\\s|[_]|[0-9]|[.]|[']|[\"]|[!]|[@]|[#]|[$]|[%]|[&]|[*]|[(]|[)]|[-]|[=]|[+]|[~]|[;]|[:]|[<]|[>]|[.]|[?]|[/]|[|]|[\\]|[{]|[}]|[\\^]");
for (var x = 0; x < document.forms[0].elements[j].value.length; x++)
{			
var match = myregexp.exec(document.forms[0].elements[j].value.substring(x));


				if (match != null) {
			
	
			} else {alert("invalid");
					j++;

}


				}
			}
		}
	}
}