Tuesday, May 5, 2009

AllowOnlyNumeric() function in Javascript

// JavaScript Function
function AllowOnlyNumeric()
{
// Get the ASCII value of the key that the user entered
var key = window.event.keyCode;
// Verify if the key entered was a numeric character (0-9) or a decimal (.)
if ( (key > 47 && key < 58) || key == 46 )
// If it was, then allow the entry to continue
return;
else
// If it was not, then dispose the key and continue with entry
window.event.returnValue = null;
}

// HTML Code

No comments:

Post a Comment

 
Locations of visitors to this page