Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Trim, Mouse Hover Pointer Functions using JAVASCRIPT

0.00/5 (No votes)
11 Feb 2012CPOL 12.6K  
Trim, Change button mouse hover pointer Functions using JavaScript

Trim Function


Function: trim
Input : ' Test Trim Function ', ''
Output: 'Test Trim Function'
Example:
JavaScript
trim(document.getElementById(varUB).value, '')

JavaScript
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.NET
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnMouseOver="onMouseOver(this);" OnMouseOut="onMouseOut(this);" />
JavaScript
function onMouseOver(btnCntl) {
    btnCntl.style.cursor = 'hand';
}
function onMouseOut(btnCntl1) {
    btnCntl1.style.cursor = 'default';
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)