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

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

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

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>

©2018 Martin Webb