One problem is that you left off semi-colons at the end of a couple of lines. Also, a couple of lines were redundant. But then that will only check that the user entered some text instead of a number. If you want to prevent them simply pressing "enter", you could check that the number isn't zero as well.
Additionally, you'd presumably want to go back to the prompt until they'd entered a number. Something like this:
Code:
<script type="text/javascript" charset="UTF-8">
var isValid = 0;
while (isValid == 0) {
var width = prompt( "Enter the width of a rectangle." );
if ( isNaN(width) || width==0 ) {
alert("You must enter a number.");
} else {
isValid = 1;
}
}
isValid = 0;
while (isValid == 0) {
var height = prompt( "Enter the height of a rectangle." );
if ( isNaN(height) || height==0 ) {
alert("You must enter a number.");
} else {
isValid = 1;
}
}
var area = parseInt(width) * parseInt(height);
alert( "The area of the rectangle is " + area);
</script>