1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript Any way to customize the JavaScript prompt box?

Discussion in 'Web Development' started by Michaelpina, Dec 17, 2012.

  1. Michaelpina

    Michaelpina New Member

    Is it possible to make a JavaScript prompt which only accept numeric input?
     
  2. javierluces

    javierluces New Member

    I found this, may be it works for you.

    Code:
    <HTML>
      <HEAD>
      <SCRIPT language=Javascript>
          <!--
          function isNumberKey(evt)
          {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
     
            return true;
          }
          //-->
      </SCRIPT>
      </HEAD>
      <BODY>
          <INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">
      </BODY>
    </HTML>