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

Q1740 How can I filter user input to leave just the numerical digits?

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

Q1740 How can I filter user input to leave just the numerical digits?

Use a Regular Expression:

<html>

<body>

<script language="JavaScript"><!--
var temp = prompt('Enter a number','23408fn2fy28fh398f928');
temp = temp.replace(/[^0-9]/g,'');
alert(temp);
//--></script>

</body>

</html>

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.