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;
 }

相关文章:

  • 2021-05-27
  • 2022-02-24
  • 2022-12-23
  • 2018-08-29
  • 2021-10-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2021-05-06
  • 2022-01-18
  • 2021-06-30
  • 2021-11-26
相关资源
相似解决方案