开发者

letters or numbers only in a password with jquery

开发者 https://www.devze.com 2022-12-24 06:27 出处:网络
I found this co开发者_开发问答de for alphanumeric check (\"Letters, numbers, spaces or underscores\") but I want to change so I will be able to write only letters or numbers. Can anyone tell me how to

I found this co开发者_开发问答de for alphanumeric check ("Letters, numbers, spaces or underscores") but I want to change so I will be able to write only letters or numbers. Can anyone tell me how to change this code:

function(value, element) {
    return this.optional(element) || /^\w+$/i.test(value);}

Thanks!

Greg


This should do it:

function(value, element)
{
    return this.optional(element) || /^[a-zA-Z0-9]+$/i.test(value);
}

EDIT: OK, no idea why I can't get that formatting nicely, but the important part is replacing the \w with the character class (the bit in []).


I've used this for years now :

http://www.itgroup.com.ph/alphanumeric/

Take a look

0

精彩评论

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

关注公众号