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

Q1604 How can I ask a user for input using a prompt and validate whether or not it is a number?

You are here: irt.org | FAQ | JavaScript | Number | Q1604 [ previous next ]

Try:

<script language="JavaScript"><!--
var val = prompt('enter an number');
while (parseInt(val) != val) {
  val = prompt('enter an number');
}
//--></script>

©2018 Martin Webb