Tuesday, June 16, 2009

Removing white spaces entered in TextArea tag of HTML page

White spaces entered in Textarea of HTML page will be considered as Characters even when no other characters are entered.

These white spaces will then be inserted into database table unnecessarily.

So, to avoid this issue the below Javascript code can be used.

It will clear the whitespaces in the Textarea.

var str=document.getElementById(“category_name”).value;
var pattern_white_space=/^\s{1,4}/g;
var pattern_any_characters=/\w+/g;


More Articles...

1 comment:

Anonymous said...

This works fine! It removes all white spaces and carriage returns from a string and returns an empty string. It works on the assumption that the input string contaings no letters, numbers, commas, etc.

Search This Blog