Sajjad’s Blog

Posts Tagged ‘Javascript

JavaScript: String trimming and padding

Posted by: msh134 on: November 19, 2008

When working with JavaScript in one of my projects I needed to trim strings and pad them. I googled for a solution and many sources I have got the following codes and sharing with you.
Trimming:
//trimming space from both side of the string
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,”");
}

//trimming space from left side of the string
String.prototype.ltrim = function() [...]

Date control using JavaScript

Posted by: msh134 on: June 21, 2008

Date control is a combination of three drop downs with month, day and year valus. It can be used as an alternative to the date picker control. Suppose a user needs to select a date before/after 10 years. At this point selecting the date with a date picker will not be easy and time consuming. [...]

Removing table rows using JavaScript

Posted by: msh134 on: June 21, 2008

In my last post I have shown how to duplicate a table row. Now if you let the user to duplicate a row then you will look for a solution to remove row dynamically using JavaScript. Use the following function to dynamically remove row from a table. This code is also tested on IE6 and [...]

Duplicating table rows dynamically

Posted by: msh134 on: June 21, 2008

For some days I was looking for a JavaScript solution for duplicating table rows. I know it is simple. But I have made a function which does this very easily. I have tested this code with IE 6.0 and FireFox 2+ browsers.
More >>