1.js中不允许!*()'字符输入 var pattern=/[\w+\W+]*(!|\*|\(|\)|\')[\w+\W+]*$/;
if (pattern.exec(utm_term)){
alert("字词中不允许包含 ! * ( ) ' 字符");
return ;
}
2.js中trim()方法替换方法
str = str.replace(/(^\s*)|(\s*$)/g, "");
3.匹配以com cn net结尾的str
patrn = /^[\w+\W+]*\.(com|cn|net)$/;
if(patrn.exec(gohighLink)){
gohighLink = gohighLink + "/"
}
4.检验数字
var patrn=/^\d*$/;
if (patrn.test(s)) {
alert( "yes ");
}else{
alert( "no ");
}
}
阅读(1826) | 评论(0) | 转发(0) |