Coding Tips Daily Blog

Programming tips, tricks and advice from Jonathan Leger, a seasoned professional programmer/analyst.
 
ASP.NET, VB.NET, Visual Basic, MS Access, MS SQL Server, PHP, MySQL, JavaScript and more!

Email Me

Monday, July 19, 2004

JavaScript Function Allow Number keys Only (only digit)

This function returns True if the passed keycode is a digit, False if it is not. This is useful when you want to limit the values of a input field to only numbers.


function isDigit(nKeyCode)
{
// Test for digit keycode (0-9).
if((nKeyCode > 47) && (nKeyCode < 58))
{
return true;
}

return false;
}
Posted by Unknown at 7:21 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Post Older Post Home

Blog Archive

  • ▼  2004 (38)
    • ▼  07/18 - 07/25 (13)
      • JavaScript Functions for Working with Cookies
      • JavaScript Form Validation Functions (validate input)
      • JavaScript Function to Validate U.S. State (valid ...
      • JavaScript Function Allow Number keys Only (only d...
      • JavaScript Function Validate Date (valid date)
      • JavaScript Function to Validate SSN (valid ssn)
      • JavaScript Function to Validate Phone Number (vali...
      • JavaScript Function Is Numeric (validate number, v...
      • JavaScript Function to Validate Email Addresses (v...
      • JavaScript Function to Validate Zip codes (valid z...
      • JavaScript Function to Trim White Space (RTRIM)
      • JavaScript Function To Trim White Space (LTRIM)
      • JavaScript Function to Format Currency (Money)
    • ►  07/04 - 07/11 (1)
    • ►  06/20 - 06/27 (1)
    • ►  05/16 - 05/23 (3)
    • ►  05/09 - 05/16 (7)
    • ►  01/25 - 02/01 (2)
    • ►  01/18 - 01/25 (4)
    • ►  01/11 - 01/18 (6)
    • ►  01/04 - 01/11 (1)

About Me

Unknown
View my complete profile
Awesome Inc. theme. Powered by Blogger.