Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1394 How can I prevent the user from typing anything else than the characters 0123456789 and '.' and return in a form field?

You are here: irt.org | FAQ | JavaScript | Form | Q1394 [ previous next ]

Try:

<html>
<head>
<title>Untitled</title>
<script language="JavaScript"><!--
function handler(e) {
     var key = (navigator.appName == "Netscape") ? e.which : e.keyCode;
     if (key == 13 || key == 46 || (key > 47 && key < 58)) return true; else return false;
}
//--></script>

</head>

<body>

<form>
<input type="text" onKeyDown="return handler(event)" onKeydown="return handler(event)">
</form>

</body>
</html>

Feedback on 'Q1394 How can I prevent the user from typing anything else than the characters 0123456789 and '.' and return in a form field?'

©2018 Martin Webb