JSP我不懂,给你个JS的做参考吧var reg = /^(\w)\1+$/;if (reg.test(document.myform.myinput.value)){ document.write('全是一样的字母或数字');}