duckstar Posted April 14, 2010 Share Posted April 14, 2010 Hi, This is going to be a very easy question for someone to answer. This code is for AlphaNumberic function isAlphaNumeric(val) { if (val.match(/^[a-zA-Z0-9]+$/)) { return true; } else { return false; } } I want it to do exactly the same, but to also allow the forwards slash "/" Is this possible ? I am not sure how to add it to (/^[a-zA-Z0-9]+$/) since i have no idea what is going on there. Thanks Duckstar Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 14, 2010 Share Posted April 14, 2010 /^[a-z\d/]+$/i Quote Link to comment Share on other sites More sharing options...
duckstar Posted April 14, 2010 Author Share Posted April 14, 2010 Thanks, Took off the "i" at the end, because it didn't like it. Quote Link to comment Share on other sites More sharing options...
duckstar Posted April 14, 2010 Author Share Posted April 14, 2010 Total lie. Works with the "i". Thanks mate. Still have no idea how that works though... Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 14, 2010 Share Posted April 14, 2010 /^[a-z\d/]+$/i ^ = matching the beginning of the line or string [a-z\d/] = character set matching any letters from a-z, any digit (\d) or a forward slash (/) + = matches the previous expression one or more time $ = matches the end of the line or string i = regular expression modifier meaning case-insensitive Quote Link to comment Share on other sites More sharing options...
duckstar Posted April 14, 2010 Author Share Posted April 14, 2010 Brilliant, Thanks again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.