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

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

irt.org | Knowledge Base | JavaScript | Number | Q1604 [ previous next ]

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

Try:

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

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.