I would like to make sure that my users only enter any combination or letters or numbers for a particular field in my JSP (case insensitive). What is the best way to do this?

Jeanne Boyarsky

You could also make an expression with letters and numbers and negate it. (While the list in the above post looks complete, you never know when you might be missing something).

function isInvalidChar(str){
	var validExp = /^[w]+$/;
	if(str.search(validExp) == -1) {
		return true;
	return false;
  1. ^ means starts with
  2. $ means ends with
  3. [^w]+ means one or more alphanumeric characters