function validate(str){ var illegalChars = ['*','-'];//指定的特殊字符写在这个数组里面,个数不限。 str = str.value; var numberCount = 0; var upperCaseCount = 0; var lowerCaseCount = 0; var otherCharCount = 0; var numberIndex = 0; var upperCaseIndex = 0; var lowerCaseInde
第一次发现Javascr ipt中replace() 方法如果直接用str.replace(“-“,”!”) 只会替换第一个匹配的字符.
而str.replace(/\-/g,”!”)则可以全部替换掉匹配的字符(g为全局标志)。
replace()
The replace() method returns the string that results when you replace text matching its first argument
(a regular expressi