Jump to content

Regular Expression Alphanumeric & Underscore


barkster

Recommended Posts

I'm trying to do a regex to allow only alphanumeric and the underscore but I can't get it to work.  I've tested on a few reg testers and it worked there but I can't get it to work on my page.

 

 

javascript

var rah = new RegExp(/([^A-Za-z0-9_])/);

if (!rah.test(f.tbgalleryname.value)) {

alert("Your folder name has illegal characters.\nCan only contain alphanumeric characters (a-z 0-9 _)");

return false;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.