letters or numbers only in a password with jquery

I found this code 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

Answers


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


Need Your Help

How do I create an Alfred workflow to search for my own, most recent posts on google plus?

search hyperlink google-plus alfred

I am trying to build an Alfred workflow to search for my own, most recent posts on google plus. The hyperlink for a search is pretty easy https://plus.google.com/u/0/s/ , but how do I restrict it t...

Phonegap/Cordova Media Class Permissions

android cordova

I am making an Android Phonegap/Cordova app which uses the Media Class found here: http://docs.phonegap.com/en/2.9.0/cordova_media_media.md.html