if(x==null || x=="")
{
alert("文本框不能为空!");
return;
}
alert("验证通过");
//正则表达式来表示一连串的空格
下面的示例演示了 replace 方法将第一次出现的单词 "The" 替换为单词 "A" 的用法。
function ReplaceDemo(){
var r, re; // 声明变量。
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = /The/g; // 创建正则表达式模式。
r = ss.replace(re, "A"); // 用 "A" 替换 "The"。
return(r); // 返回替换后的字符串。
}
var re=/string名/gi;
g表示全局查找,
i表示不区分大小写;
{
alert("文本框不能为空!");
return;
}
alert("验证通过");
//正则表达式来表示一连串的空格
下面的示例演示了 replace 方法将第一次出现的单词 "The" 替换为单词 "A" 的用法。
function ReplaceDemo(){
var r, re; // 声明变量。
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = /The/g; // 创建正则表达式模式。
r = ss.replace(re, "A"); // 用 "A" 替换 "The"。
return(r); // 返回替换后的字符串。
}
var re=/string名/gi;
g表示全局查找,
i表示不区分大小写;