Edit in JSFiddle

function IsInt(event) {
    var chCode = ('charCode' in event) ? event.charCode : event.keyCode;
    if (chCode >= 48 && chCode <= 57) {
        return true;
    } else {
        alert('Numbers only');
        return false;
    }
}
<a href='http://z54.com'>Javascript Data Input Validation</a><br>
Only Numbers Allowed Example: <input type='text' onkeypress='return IsInt(event)' />