• All
  • Free Web Hosting
  • Category 2
gravatar

How to Accept Numeric Characters Only in Javascript?

Create a textbox in your HTML or PHP Program, Then insert this code after the HEAD on your HTML code.

<script language="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
}
</script>