Remove Special Characters (like !, %, &, #) from String | Javascript

No, this post is not about dieting or anything like that… but to remove Special Kharacters. To do this, I was going to use a for loop in javascript that checks each character and if it is not between ‘A’ and ‘Z’, the character will be removed. Until I found this code lying around on the net which makes removing special characters very simple…

function removeSpecialChars(strVal)
strVal = strVal.replace(/[^a-zA-Z 0-9]+/g,”);


Response End

This is added after the text needed in the response stream is written using the Response.Write() so no other html or garbage is written in the response stream.

Without response.end() javascript will have the text and the remaining garbage.

[ex. 1] without response.end()

result =”err

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>
<html xmlns=”” ><head><link href=”../App_Themes/Default/Content.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Default.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/EmailSender.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Header.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Header2.css” type=”text/css” rel=”stylesheet” /><link href=”../App_Themes/Default/Sidebar.css” type=”text/css” rel=”stylesheet” /><title> </title></head><body>    <form name=”form1″ method=”post” action=”WebService.aspx” id=”form1″><div><input type=”hidden” name=”__VIEWSTATE” id=”__VIEWSTATE” value=”/wEPZwUPOGNjY2JiNjJiNWQ5MDI41In2qlnOWzD0wbpAPF80y1dPYTA=” /></div>
</form></body></html>” Continue reading

Calling Web Service From Javascript

Hi my post explains how to call web service frm java script using AJAX.

If the web service class on the server includes a web method that does not return data, you can call the web service without having to handle a response. This is the simplest web method call that can be made from the client. For example, your application has the following web method:

Continue reading

Unselectable Text

There are many methods and options to make text unselectable on a website, but not all of them work on the major browsers. Below please find different source code to help you achieve this.

If you combine all the below source codes together in the same html/asp/aspx form, you’ll get all their functionality on the same page, thus no one can select any text from your website from the following browsers:

  • Internet Explorer 7
  • Firefox 3.0.4
  • Google Chrome 0.4.x
  • Opera 9.62

Source Code 1 – Unselectable

var Unselectable = {

enable : function(e) {
var e = e ? e : window.event;

if (e.button != 1) {
if ( {
var targer =;
} else if (e.srcElement) {
var targer = e.srcElement;

var targetTag = targer.tagName.toLowerCase();
if ((targetTag != “input”) && (targetTag != “textarea”)) {
return false;

disable : function () {
return true;


if (typeof(document.onselectstart) != “undefined”) {
document.onselectstart = Unselectable.enable;
} else {
document.onmousedown = Unselectable.enable;
document.onmouseup = Unselectable.disable;

You need to insert this in the <head> section of the html form in the following form: Continue reading