您的位置:首页 > 其它

有关正则表达式的研究

2010-10-08 16:48 323 查看
var regexpress = "^[1-9]\\d*$";

var yesno= (new RegExp(regexpress, "")).test("要验证的值");

另一种正则使用方法

if(/^1[0-9]{10}$/.test(mobile))

{

$('sp_mobile').innerHTML='';

$('sp_mobile').className="";

ismobile=true;

}else

{

$('sp_mobile').innerHTML='手机格式不正确';

$('sp_mobile').className="red";

ismobile=false;

}

if(/^[-]?\d+$/.test(pricemin)||pricemin=='')
{
ispricemin=true;
}
else
{
$('sp_allowprice').innerHTML='请输入整数';
ispricemin=false;
}


输入长度的判断

if (jQuery("#Words").val().replace(/[^\x00-\xff]/g, "**").length > 500) {

alert("最多输入250个汉字");
return;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: