Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form | Q1394 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.