We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

Basicallly When we trying to validate a form some time we need numeric validation for textbox.
 
We can validate textbox by onkeypress event of the control By checking whether the keycode of the key pressed as the user types falls within the range of the number keys 48-57(i.e 0-9 and '.') ,if not belong to that range it will return false then it will disable the keypress action
function NumericValidation(eventObj)
{
    var keycode;
 
    if(eventObj.keyCode) //For IE
        keycode = eventObj.keyCode;
    else if(eventObj.Which)
        keycode = eventObj.Which;  // For FireFox
    else
        keycode = eventObj.charCode; // Other Browser
 
    if (keycode!=8) //if the key is the backspace key
    {
        if (keycode<48||keycode>57) //if not a number
            return false; // disable key press
        else
            return true; // enable key press
     }
        
 }


Related Tags:

Javascript

Author: Biswajit Satapathy

top

Related Pages

  • RIA/AJAX Programming Skills
  • Web Application Projects

JavaScript

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login