验证常用邮箱:
- var mailstr = /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int|name|com.cn|net.cn|cn|cc)$/;
var mailstr = /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int|name|com.cn|net.cn|cn|cc)$/;
验证常用手机:
- var mytel = /^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
var mytel = /^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
验证不带区号固定开头的固话:
- var myphone = /^((\8|6)+(\d{7}))?$/;
var myphone = /^((\8|6)+(\d{7}))?$/;
验证固定长度的数字:
- var mynumber = /^((\d{5}))?$/;
var mynumber = /^((\d{5}))?$/;
去掉空格:
- //去掉空格
- function trim(str)
- {
- for(var i=0;i<str.length&&str.charAt(i)==" ";i++);
- for(var j=str.length;j>0&&str.charAt(j-1)==" ";j--);
- if(i>j) return "";
- return str.substring(i,j);
- }
//去掉空格 function trim(str) { for(var i=0;i<str.length&&str.charAt(i)==" ";i++); for(var j=str.length;j>0&&str.charAt(j-1)==" ";j--); if(i>j) return ""; return str.substring(i,j); }