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;
if(str.match(pattern_white_space)&&!str.match(pattern_any_characters))
{
document.getElementById(“category_name”).value="";
}
More Articles...
1 comment:
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.
Post a Comment