I need to validate a textbox which can only takes numbers. So i'm using the code below. It passes a message to the user but it also writes the alphabet to the textbox. I don't want anything written when user enters an alphabet.
<script type="text/javascript">
function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("This field can only contain numbers.");
        return false;
    }
    return true;
}
</script>
 
     
     
    