DBB
asked on
prevent links in text area
Hi,
What's the best way to disallow links in textarea inputs?
Thanks
Dbb
What's the best way to disallow links in textarea inputs?
Thanks
Dbb
ASKER
Thought so,
I just wandered if there was a tag to use or something
Thanks
Dbb
I just wandered if there was a tag to use or something
Thanks
Dbb
Nope, there's nothing like a "strip links from textareas" tag...unfortunately.. ;)
Regards,
Max.
Regards,
Max.
ASKER
Didn't think so, ah well...
Dbb
Dbb
this will stop all links in the texarea
<script>
function stripLinks(obj){
reg=/<a[^>]+>[^>]+<\/a>/gi
obj.value=obj.value.replac e(reg,'')
}
</script>
<textarea onblur="stripLinks(this)" onkeyup="this.onblur()" cols="40" rows="15"></textarea>
<script>
function stripLinks(obj){
reg=/<a[^>]+>[^>]+<\/a>/gi
obj.value=obj.value.replac
}
</script>
<textarea onblur="stripLinks(this)" onkeyup="this.onblur()" cols="40" rows="15"></textarea>
reg=/< *a[^>]+>[^>]+< *\/a *>/gi
is slightly better
is slightly better
That probably won't stop:
this:
<div style="cursor: pointer; color: blue" onmouseover="this.style.te xtDecorati on='underl ine'" onmouseout="this.style.tex tDecoratio n=''" onclick="location.href='http://kiddanger.com/'"> kiddanger. com</div>
or this:
<span style="cursor: pointer; color: blue" onmouseover="this.style.te xtDecorati on='underl ine'" onmouseout="this.style.tex tDecoratio n=''" onclick="location.href='http://kiddanger.com/'"> kiddanger. com</span>
or this:
<select name="goaway" onchange="location.href=th is.options [this.sele ctedIndex] .value">
<option value="" selected>Where do you want to go today?</option>
<option value="http://microsoft.com/">microsoft</option >
<option value="https://www.experts-exchange.com/">experts exchange</option>
<option value="http://hp.com/">hp</option>
</select>
or this:
<img style="cursor: pointer; border: 5px outset blue" onmouseover="this.style.bo rder='5px inset blue'" onmouseout="this.style.bor der='5px outset blue'" src="http://i.microsoft.com/h/en-us/r/ms_masthead_ltr.gif" onclick="location.href='http://microsoft.com/'" title="who's your daddy?" />
http://kiddanger.com/lab/ee/talinks.html
this:
<div style="cursor: pointer; color: blue" onmouseover="this.style.te
or this:
<span style="cursor: pointer; color: blue" onmouseover="this.style.te
or this:
<select name="goaway" onchange="location.href=th
<option value="" selected>Where do you want to go today?</option>
<option value="http://microsoft.com/">microsoft</option
<option value="https://www.experts-exchange.com/">experts exchange</option>
<option value="http://hp.com/">hp</option>
</select>
or this:
<img style="cursor: pointer; border: 5px outset blue" onmouseover="this.style.bo
http://kiddanger.com/lab/ee/talinks.html
ASKER
Anyone got a quick script that'll strip the entire url?
Thanks
Dbb
Thanks
Dbb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
can you not strip between <a href> and </a>?
Well..you could...but what if the link is done the way kiddanger described? Then the link is still there...
Regards,
Max.
Regards,
Max.
ASKER
Sorry, just realised that after I posted...
I think this was a good discussion. I didn't realize the difficulty until I started looking at it. I don't know why, but I chose a long time ago to just show the text in either <xmp> or <pre></pre> and this renders the links to merely visual.
ASKER
Thanks Kiddanger, your input is much appreciated. As is from everyone else.
Thanks guys
Dbb
Thanks guys
Dbb
Glad to have been helpfull :)
Regards,
Max.
Regards,
Max.
You're welcome, DBB.
Regards,
Max.