12" />
开发者

Number of characters in a string

开发者 https://www.devze.com 2023-01-22 12:41 出处:网络
var a=开发者_如何学运维\"password\"; In any variable how to check if the length is not less than 6 charactersand not> 12
       var a=开发者_如何学运维"password";

In any variable how to check if the length is not less than 6 characters and not > 12

     $(a).len();?????


No need for jQuery.

if ((a.length < 6) || (a.length > 12)) { error .... }

MDC reference on string.length

MDC reference on the String object


if (a.length < 6 || a.length > 12) {
    alert('Invalid password. It must be between 6 and 12 characters long');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消