0
in script tag
      function ispwd() { 
            var pwdreg= ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$;  //here '^' and '\' are               shown invalid characters 
            var pwdval=$("#pwd").val();
            if(!pwdreg.test(pwdval))
            {        
            $("#pwd").after('<span class="error">the password must be 4-8 chars and include at least one upper case letter, one lower case letter, and one numeric digit.</span>');
            $("#pwd").focus();
            }
            }

in html
<p>Password<input type="password" id="pwd" onblur="ispwd()"/></p>

onblur from password 错误提示 javascript error: 'ispwd' is not defined。

4

1 回答 1

1

Javascript 正则表达式文字必须包含在/.../字符中。

于 2013-07-08T14:17:36.933 回答