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
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact