65.9K
CodeProject is changing. Read more.
Home

Trim, Mouse Hover Pointer Functions using JAVASCRIPT

starIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

1.00/5 (2 votes)

Feb 11, 2012

CPOL
viewsIcon

12633

Trim, Change button mouse hover pointer Functions using JavaScript

Trim Function

Function: trim Input : ' Test Trim Function ', '' Output: 'Test Trim Function' Example:
trim(document.getElementById(varUB).value, '')
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

Change Button Mouse Hover Pointer

Input: Button control client id Example:
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnMouseOver="onMouseOver(this);" OnMouseOut="onMouseOut(this);" />
function onMouseOver(btnCntl) {
    btnCntl.style.cursor = 'hand';
}
function onMouseOut(btnCntl1) {
    btnCntl1.style.cursor = 'default';
}