JavaScript string replace for post slug Aug22 '05

Feedback

# (1 of 7): Dale » bluetrait.com

13 hours, 43 minutes after the fact. (Tue 23 Aug 2005, 1:10 AM CST)

I do that based on a php function so that clients don't need to have javascript going.

Also it is a good idea to check input because the javascript stuff can be changed.

/off topic:

Have you been getting any spam through your contact form?

Also you have "" at the very top left hand side of your website, I've had that issue before, something to do with Dreamweaver I think.

# (2 of 7): Matthom

20 hours, 20 minutes after the fact. (Tue 23 Aug 2005, 7:48 AM CST)


Have you been getting any spam through your contact form?

Ever since I added the security check, spam has dwindled considerably. However, I still think it's capable of getting through.


Also you have "" at the very top left hand side of your website, I've had that issue before, something to do with Dreamweaver I think.

Well... I don't use Dreamweaver - so it can't be that... I don't like it, though. I wish I knew how to get rid of it.

Previous comment Return to entry

# (3 of 7): Xivoid

2 years after the fact. (Sat 25 Aug 2007, 9:20 AM CST)

document.fors.[...].elements is null or not an object

Previous comment Return to entry

# (4 of 7): Steve » sleepingawake.net

2 years, 6 months after the fact. (Wed 20 Feb 2008, 11:04 AM CST)

Thanks for this, I updated it to replace spaces with dashes and remove anything but alpha-numeric characters and dashes. Here's what it looks like...

function sectionWebSafe(original) { // replace spaces with dashes var originalarray = original.split(" ") var webSafe = originalarray.join("-") // remove special characters var originalarray = webSafe.split(RegExp("[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-]")) var webSafe = originalarray.join("") return webSafe.toLowerCase(); }

Previous comment Return to entry

# (5 of 7): Techlands » techlands.com

3 years, 1 month after the fact. (Fri 10 Oct 2008, 12:30 PM CST)

here is an updated one that strips anything not alphanumeric except hyphen

Suggest

Previous comment Return to entry

# (6 of 7): Techlands » techlands.com

3 years, 1 month after the fact. (Fri 10 Oct 2008, 12:34 PM CST)

Added strip whitespace at the front and end




bfc757512077c4a08711c99143ef0cc7






c936661a0476574a0893147cf12d4881





Previous comment Return to entry

# (7 of 7): Techlands » techlands.com

3 years, 1 month after the fact. (Fri 10 Oct 2008, 12:34 PM CST)

Suggest

Previous comment Return to entry

RSS feed for comments on this post

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Return to entry.

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

A simple JavaScript string replace function, for possible use on blog administration panels.

You are at the feedback permalink page for: JavaScript string replace for post slug

Read more...