DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Help with JS function

This is a discussion on Help with JS function within the JavaScript Programming forums, part of the Programming & Scripting category; Help! I'm no javascript programmer, but sometimes it can't be avoided. I'd willingly try to figure this out, but I'm ...

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

  #1  
Old June 5th, 2009, 03:52 PM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default Help with JS function

Help! I'm no javascript programmer, but sometimes it can't be avoided. I'd willingly try to figure this out, but I'm on deadline.

I need a statement or two that will remove any character from a string that is NOT a capital letter or a number; thus:
Code:
O'HARA-SMITH_JANE_Q1
would become
OHARASMITH_JANE_Q1
If you are feeling truly magnanimous, I also need a regex validator for same (but can include lower case characters, since I toUpper the string before I store it).

Mega cudos in advance.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
  #2  
Old June 9th, 2009, 09:52 AM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default

OK - so I had to crack open my almost untouched JavaScript reference, but found what I was looking for. For the lurkers who might be looking for an answer like this, I coded:
Code:
 urlBox.value = urlText.replace(/[^\w\d_]*/gi, "")
Q.E.D.

Comments on this post
jmurrayhead agrees: Thanked Post
richyrich agrees: Thanks for posting Wolffy.....Regex isn't really my forte!!
Reply With Quote
The Following User Says Thank You to Wolffy For This Useful Post:
jmurrayhead (June 9th, 2009)
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Using InStr Function todd2006 ASP Development 2 April 24th, 2009 09:59 AM
calling function guddu ASP Development 3 November 5th, 2008 09:34 AM
[Functions] Help using function Rebelle ASP Development 11 October 13th, 2008 12:13 PM
ASP 2 way encryption function dr_rock ASP Development 2 August 14th, 2008 08:01 AM
without function guddu Microsoft SQL Server 1 July 15th, 2008 04:02 PM


All times are GMT -4. The time now is 06:34 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2